Skip to content

Commit a8d9bb7

Browse files
committed
fix: more tests
1 parent b3469ad commit a8d9bb7

File tree

1 file changed

+32
-15
lines changed

1 file changed

+32
-15
lines changed

test/runner/step-sections_test.js

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import chai from 'chai';
2-
chai.should();
3-
import { expect } from 'expect';
4-
import { exec } from 'child_process';
5-
import path from 'path';
6-
import { codecept_dir, codecept_run } from './consts.js';
7-
import debugFactory from 'debug';
8-
const debug = debugFactory('codeceptjs:tests');
9-
import { fileURLToPath } from 'url';
10-
const __filename = fileURLToPath(import.meta.url);
11-
const __dirname = path.dirname(__filename);
1+
import chai from 'chai'
2+
chai.should()
3+
import { expect } from 'expect'
4+
import { exec } from 'child_process'
5+
import path from 'path'
6+
import { codecept_dir, codecept_run } from './consts.js'
7+
import debugFactory from 'debug'
8+
const debug = debugFactory('codeceptjs:tests')
9+
import { fileURLToPath } from 'url'
10+
const __filename = fileURLToPath(import.meta.url)
11+
const __dirname = path.dirname(__filename)
1212

1313
const config_run_config = (config, grep) => `${codecept_run} --steps --config ${codecept_dir}/configs/step-sections/${config} ${grep ? `--grep "${grep}"` : ''}`
1414

@@ -22,9 +22,16 @@ describe('CodeceptJS step-sections', function () {
2222
expect(stdout).toContain('User Journey')
2323
expect(stdout).toContain('Nothing to say')
2424

25-
const expectedOutput = [' I am in path "."', ' User Journey', ' I act "Hello, World!"', ' I act "Nothing to say"'].join('\n')
25+
// Check for the step structure (allowing for timing info in between)
26+
expect(stdout).toContain('I am in path "."')
27+
expect(stdout).toContain('User Journey')
28+
expect(stdout).toContain('I act "Hello, World!"')
29+
expect(stdout).toContain('I act "Nothing to say"')
30+
31+
// Verify the indentation structure for sections
32+
expect(stdout).toMatch(/\s+User Journey/)
33+
expect(stdout).toMatch(/\s+I act "Hello, World!"/)
2634

27-
expect(stdout).toContain(expectedOutput)
2835
expect(err).toBeFalsy()
2936
done()
3037
})
@@ -36,9 +43,19 @@ describe('CodeceptJS step-sections', function () {
3643
expect(stdout).toContain('OK')
3744
expect(stdout).toContain('User Journey')
3845

39-
const expectedOutput = [' User Journey', ' On userPage: act on page', ' I act "actOnPage"', ' I act "see on this page"', ' I act "One more step"', ' I act "Nothing to say"'].join('\n')
46+
// Check for the step structure (allowing for timing info in between)
47+
expect(stdout).toContain('User Journey')
48+
expect(stdout).toContain('On userPage: act on page')
49+
expect(stdout).toContain('I act "actOnPage"')
50+
expect(stdout).toContain('I act "see on this page"')
51+
expect(stdout).toContain('I act "One more step"')
52+
expect(stdout).toContain('I act "Nothing to say"')
53+
54+
// Verify the indentation structure for sections and nested steps
55+
expect(stdout).toMatch(/\s+User Journey/)
56+
expect(stdout).toMatch(/\s+On userPage: act on page/)
57+
expect(stdout).toMatch(/\s+I act "actOnPage"/)
4058

41-
expect(stdout).toContain(expectedOutput)
4259
expect(err).toBeFalsy()
4360
done()
4461
})

0 commit comments

Comments
 (0)