1- const assert = require ( 'assert' )
2- const path = require ( 'path' )
3- const fs = require ( 'fs' )
4- const exec = require ( 'child_process' ) . exec
1+ import assert from 'assert' ;
2+ import path from 'path' ;
3+ import fs from 'fs' ;
4+ import { exec } from 'child_process' ;
55
6- const runner = path . join ( __dirname , '/../../bin/codecept.js' )
7- const codecept_dir = path . join ( __dirname , '/../data/sandbox/configs/gherkin/' )
6+ const runner = path . join ( path . dirname ( import . meta . url ) , '/../../bin/codecept.js' ) ;
7+ const codecept_dir = path . join ( path . dirname ( import . meta . url ) , '/../data/sandbox/configs/gherkin/' ) ;
88
99describe ( 'gherkin bdd commands' , ( ) => {
1010 describe ( 'bdd:init' , ( ) => {
11- const codecept_dir_js = path . join ( codecept_dir , 'config_js' )
12- const codecept_dir_ts = path . join ( codecept_dir , 'config_ts' )
11+ const codecept_dir_js = path . join ( codecept_dir , 'config_js' ) ;
12+ const codecept_dir_ts = path . join ( codecept_dir , 'config_ts' ) ;
1313
1414 beforeEach ( ( ) => {
1515 fs . copyFileSync (
1616 path . join ( codecept_dir_js , 'codecept.conf.init.js' ) ,
1717 path . join ( codecept_dir_js , 'codecept.conf.js' ) ,
18- )
18+ ) ;
1919 fs . copyFileSync (
2020 path . join ( codecept_dir_ts , 'codecept.conf.init.ts' ) ,
2121 path . join ( codecept_dir_ts , 'codecept.conf.ts' ) ,
22- )
23- } )
22+ ) ;
23+ } ) ;
2424
2525 afterEach ( ( ) => {
2626 try {
27- fs . rmSync ( path . join ( codecept_dir_js , 'codecept.conf.js' ) )
27+ fs . rmSync ( path . join ( codecept_dir_js , 'codecept.conf.js' ) ) ;
2828 fs . rmSync ( path . join ( codecept_dir_js , 'features' ) , {
2929 recursive : true ,
30- } )
30+ } ) ;
3131 fs . rmSync ( path . join ( codecept_dir_js , 'step_definitions' ) , {
3232 recursive : true ,
33- } )
33+ } ) ;
3434 } catch ( e ) {
3535 // catch some error
3636 }
3737 try {
38- fs . rmSync ( path . join ( codecept_dir_ts , 'codecept.conf.ts' ) )
38+ fs . rmSync ( path . join ( codecept_dir_ts , 'codecept.conf.ts' ) ) ;
3939 fs . rmSync ( path . join ( codecept_dir_ts , 'features' ) , {
4040 recursive : true ,
41- } )
41+ } ) ;
4242 fs . rmSync ( path . join ( codecept_dir_ts , 'step_definitions' ) , {
4343 recursive : true ,
44- } )
44+ } ) ;
4545 } catch ( e ) {
4646 // catch some error
4747 }
48- } )
49- ; [
48+ } ) ;
49+ [
5050 {
5151 codecept_dir_test : codecept_dir_js ,
5252 extension : 'js' ,
@@ -58,23 +58,23 @@ describe('gherkin bdd commands', () => {
5858 ] . forEach ( ( { codecept_dir_test, extension } ) => {
5959 it ( `prepare CodeceptJS to run feature files (codecept.conf.${ extension } )` , ( done ) => {
6060 exec ( `${ runner } gherkin:init ${ codecept_dir_test } ` , ( err , stdout ) => {
61- let dir = path . join ( codecept_dir_test , 'features' )
61+ let dir = path . join ( codecept_dir_test , 'features' ) ;
6262
63- stdout . should . include ( 'Initializing Gherkin (Cucumber BDD) for CodeceptJS' )
64- stdout . should . include ( `Created ${ dir } , place your *.feature files in it` )
65- stdout . should . include ( 'Created sample feature file: features/basic.feature' )
63+ stdout . should . include ( 'Initializing Gherkin (Cucumber BDD) for CodeceptJS' ) ;
64+ stdout . should . include ( `Created ${ dir } , place your *.feature files in it` ) ;
65+ stdout . should . include ( 'Created sample feature file: features/basic.feature' ) ;
6666
67- dir = path . join ( codecept_dir_test , 'step_definitions' )
68- stdout . should . include ( `Created ${ dir } , place step definitions into it` )
69- stdout . should . include ( `Created sample steps file: step_definitions/steps.${ extension } ` )
70- assert ( ! err )
67+ dir = path . join ( codecept_dir_test , 'step_definitions' ) ;
68+ stdout . should . include ( `Created ${ dir } , place step definitions into it` ) ;
69+ stdout . should . include ( `Created sample steps file: step_definitions/steps.${ extension } ` ) ;
70+ assert ( ! err ) ;
7171
72- const configResult = fs . readFileSync ( path . join ( codecept_dir_test , `codecept.conf.${ extension } ` ) ) . toString ( )
73- configResult . should . contain ( "features: './features/*.feature'" )
74- configResult . should . contain ( `steps: ['./step_definitions/steps.${ extension } ']` )
75- done ( )
76- } )
77- } )
78- } )
79- } )
80- } )
72+ const configResult = fs . readFileSync ( path . join ( codecept_dir_test , `codecept.conf.${ extension } ` ) ) . toString ( ) ;
73+ configResult . should . contain ( "features: './features/*.feature'" ) ;
74+ configResult . should . contain ( `steps: ['./step_definitions/steps.${ extension } ']` ) ;
75+ done ( ) ;
76+ } ) ;
77+ } ) ;
78+ } ) ;
79+ } ) ;
80+ } ) ;
0 commit comments