@@ -29,6 +29,7 @@ import {
29
29
parseTaskAndArguments ,
30
30
} from "../../../src/internal/cli/main.js" ;
31
31
import { resetHardhatRuntimeEnvironmentSingleton } from "../../../src/internal/hre-singleton.js" ;
32
+ import { getHardhatVersion } from "../../../src/internal/utils/package.js" ;
32
33
import { useFixtureProject } from "../../helpers/project.js" ;
33
34
34
35
async function getTasksAndHreEnvironment (
@@ -82,26 +83,25 @@ describe("main", function () {
82
83
describe ( "version" , function ( ) {
83
84
useFixtureProject ( "cli/parsing/base-project" ) ;
84
85
85
- // TODO: as soon as the 'version task' is done, this test should be updated
86
- it . todo (
87
- "should print the version and instantly return" ,
88
- async function ( ) {
89
- const lines : string [ ] = [ ] ;
86
+ it ( "should print the version and instantly return" , async function ( ) {
87
+ const lines : string [ ] = [ ] ;
90
88
91
- const command = "npx hardhat --version" ;
92
- const cliArguments = command . split ( " " ) . slice ( 2 ) ;
89
+ const command = "npx hardhat --version" ;
90
+ const cliArguments = command . split ( " " ) . slice ( 2 ) ;
93
91
94
- await main ( cliArguments , ( msg ) => {
95
- lines . push ( msg ) ;
96
- } ) ;
92
+ await main ( cliArguments , ( msg ) => {
93
+ lines . push ( msg ) ;
94
+ } ) ;
97
95
98
- assert . equal ( lines . length , 1 ) ;
99
- assert . equal ( lines [ 0 ] , "3.0.0" ) ;
100
- // Check that the process exits right after printing the version, the remaining parsing logic should not be executed
101
- const tasksResults = await getTasksAndSubtaskResults ( ) ;
102
- assert . equal ( tasksResults . wasParam1Used , false ) ;
103
- } ,
104
- ) ;
96
+ // Get the expected package version
97
+ const expectedVersion = await getHardhatVersion ( ) ;
98
+
99
+ assert . equal ( lines . length , 1 ) ;
100
+ assert . equal ( lines [ 0 ] , expectedVersion ) ;
101
+ // Check that the process exits right after printing the version, the remaining parsing logic should not be executed
102
+ const tasksResults = await getTasksAndSubtaskResults ( ) ;
103
+ assert . equal ( tasksResults . wasParam1Used , false ) ;
104
+ } ) ;
105
105
} ) ;
106
106
107
107
describe ( "show-stack-traces" , function ( ) {
0 commit comments