|
1 |
| -const assert = require("assert"); |
2 |
| -const path = require("path"); |
3 |
| -const fs = require("fs"); |
4 |
| -const exec = require("child_process").exec; |
| 1 | +const assert = require('assert'); |
| 2 | +const path = require('path'); |
| 3 | +const fs = require('fs'); |
| 4 | +const exec = require('child_process').exec; |
5 | 5 |
|
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(__dirname, '/../../bin/codecept.js'); |
| 7 | +const codecept_dir = path.join(__dirname, '/../data/sandbox/configs/gherkin/'); |
8 | 8 |
|
9 |
| -describe("gherkin bdd commands", () => { |
10 |
| - describe("bdd:init", () => { |
11 |
| - let codecept_dir_js = path.join(codecept_dir, "config_js"); |
12 |
| - let codecept_dir_ts = path.join(codecept_dir, "config_ts"); |
| 9 | +describe('gherkin bdd commands', () => { |
| 10 | + 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'); |
13 | 13 |
|
14 | 14 | beforeEach(() => {
|
15 | 15 | fs.copyFileSync(
|
16 |
| - path.join(codecept_dir_js, "codecept.conf.init.js"), |
17 |
| - path.join(codecept_dir_js, "codecept.conf.js") |
| 16 | + path.join(codecept_dir_js, 'codecept.conf.init.js'), |
| 17 | + path.join(codecept_dir_js, 'codecept.conf.js'), |
18 | 18 | );
|
19 | 19 | fs.copyFileSync(
|
20 |
| - path.join(codecept_dir_ts, "codecept.conf.init.ts"), |
21 |
| - path.join(codecept_dir_ts, "codecept.conf.ts") |
| 20 | + path.join(codecept_dir_ts, 'codecept.conf.init.ts'), |
| 21 | + path.join(codecept_dir_ts, 'codecept.conf.ts'), |
22 | 22 | );
|
23 | 23 | });
|
24 | 24 |
|
25 | 25 | afterEach(() => {
|
26 | 26 | try {
|
27 |
| - fs.rmSync(path.join(codecept_dir_js, "codecept.conf.js")); |
28 |
| - fs.rmSync(path.join(codecept_dir_js, "features"), { |
| 27 | + fs.rmSync(path.join(codecept_dir_js, 'codecept.conf.js')); |
| 28 | + fs.rmSync(path.join(codecept_dir_js, 'features'), { |
29 | 29 | recursive: true,
|
30 | 30 | });
|
31 |
| - fs.rmSync(path.join(codecept_dir_js, "step_definitions"), { |
| 31 | + fs.rmSync(path.join(codecept_dir_js, 'step_definitions'), { |
32 | 32 | recursive: true,
|
33 | 33 | });
|
34 |
| - } catch (e) {} |
| 34 | + } catch (e) { |
| 35 | + // catch some error |
| 36 | + } |
35 | 37 | try {
|
36 |
| - fs.rmSync(path.join(codecept_dir_ts, "codecept.conf.ts")); |
37 |
| - fs.rmSync(path.join(codecept_dir_ts, "features"), { |
| 38 | + fs.rmSync(path.join(codecept_dir_ts, 'codecept.conf.ts')); |
| 39 | + fs.rmSync(path.join(codecept_dir_ts, 'features'), { |
38 | 40 | recursive: true,
|
39 | 41 | });
|
40 |
| - fs.rmSync(path.join(codecept_dir_ts, "step_definitions"), { |
| 42 | + fs.rmSync(path.join(codecept_dir_ts, 'step_definitions'), { |
41 | 43 | recursive: true,
|
42 | 44 | });
|
43 |
| - } catch (e) {} |
| 45 | + } catch (e) { |
| 46 | + // catch some error |
| 47 | + } |
44 | 48 | });
|
45 | 49 |
|
46 | 50 | [
|
47 | 51 | {
|
48 | 52 | codecept_dir_test: codecept_dir_js,
|
49 |
| - extension: "js", |
| 53 | + extension: 'js', |
50 | 54 | },
|
51 | 55 | {
|
52 | 56 | codecept_dir_test: codecept_dir_ts,
|
53 |
| - extension: "ts", |
| 57 | + extension: 'ts', |
54 | 58 | },
|
55 | 59 | ].forEach(({ codecept_dir_test, extension }) => {
|
56 | 60 | it(`prepare CodeceptJS to run feature files (codecept.conf.${extension})`, (done) => {
|
57 | 61 | exec(`${runner} gherkin:init ${codecept_dir_test}`, (err, stdout) => {
|
58 |
| - let dir = path.join(codecept_dir_test, "features"); |
| 62 | + let dir = path.join(codecept_dir_test, 'features'); |
59 | 63 |
|
60 | 64 | stdout.should.include(
|
61 |
| - "Initializing Gherkin (Cucumber BDD) for CodeceptJS" |
| 65 | + 'Initializing Gherkin (Cucumber BDD) for CodeceptJS', |
62 | 66 | );
|
63 | 67 | stdout.should.include(
|
64 |
| - `Created ${dir}, place your *.feature files in it` |
| 68 | + `Created ${dir}, place your *.feature files in it`, |
65 | 69 | );
|
66 | 70 | stdout.should.include(
|
67 |
| - "Created sample feature file: features/basic.feature" |
| 71 | + 'Created sample feature file: features/basic.feature', |
68 | 72 | );
|
69 | 73 |
|
70 |
| - dir = path.join(codecept_dir_test, "step_definitions"); |
| 74 | + dir = path.join(codecept_dir_test, 'step_definitions'); |
71 | 75 | stdout.should.include(
|
72 |
| - `Created ${dir}, place step definitions into it` |
| 76 | + `Created ${dir}, place step definitions into it`, |
73 | 77 | );
|
74 | 78 | stdout.should.include(
|
75 |
| - `Created sample steps file: step_definitions/steps.${extension}` |
| 79 | + `Created sample steps file: step_definitions/steps.${extension}`, |
76 | 80 | );
|
77 | 81 | assert(!err);
|
78 | 82 |
|
79 | 83 | const configResult = fs
|
80 | 84 | .readFileSync(
|
81 |
| - path.join(codecept_dir_test, `codecept.conf.${extension}`) |
| 85 | + path.join(codecept_dir_test, `codecept.conf.${extension}`), |
82 | 86 | )
|
83 | 87 | .toString();
|
84 |
| - configResult.should.contain(`features: './features/*.feature'`); |
| 88 | + configResult.should.contain('features: \'./features/*.feature\''); |
85 | 89 | configResult.should.contain(
|
86 |
| - `steps: ['./step_definitions/steps.${extension}']` |
| 90 | + `steps: ['./step_definitions/steps.${extension}']`, |
87 | 91 | );
|
88 | 92 | done();
|
89 | 93 | });
|
|
0 commit comments