-
-
Notifications
You must be signed in to change notification settings - Fork 751
Expand file tree
/
Copy pathwithin_test.js
More file actions
90 lines (71 loc) · 3.89 KB
/
within_test.js
File metadata and controls
90 lines (71 loc) · 3.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import * as chai from 'chai'
chai.should()
import path from 'path'
import { exec } from 'child_process'
import { fileURLToPath } from 'url'
import { test } from '../../lib/utils.js'
const { grepLines } = test
const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)
const runner = path.join(__dirname, '/../../bin/codecept.js')
const codecept_dir = path.join(__dirname, '/../data/sandbox')
const codecept_run = `${runner} run --config ${codecept_dir}/codecept.within.json `
let testStatus
describe('CodeceptJS within', function () {
this.timeout(40000)
before(() => {
global.codecept_dir = path.join(__dirname, '/../data/sandbox')
})
it('should execute if no generators', done => {
exec(`${codecept_run} --debug`, (_err, stdout) => {
const lines = stdout.match(/\S.+/g)
const withoutGeneratorList = grepLines(lines, 'Check within without generator', 'Check within with generator. Yield is first in order')
testStatus = withoutGeneratorList.find(line => line.includes('OK'))
testStatus.should.include('OK')
const stepsList = withoutGeneratorList.filter(line => !line.includes('OK'))
stepsList.should.eql(
['Scenario()', 'I small promise ', 'I small promise was finished ', 'I hey! i am within begin. i get blabla ', 'Within "blabla"', 'I small promise ', 'I small promise was finished ', 'I oh! i am within end( '],
'check steps execution order',
)
done()
})
})
it('should execute with async/await. Await is first in order', done => {
exec(`${codecept_run} --debug`, (_err, stdout) => {
// Check that the test passed by looking for success indicators
stdout.should.include('✔ OK')
const lines = stdout.match(/\S.+/g)
const withGeneratorList = grepLines(lines, 'Check within with async/await. Await is first in order', 'Check within with async/await. Await is second in order')
// Filter out status lines to get just the step executions
const stepsList = withGeneratorList.filter(line => !line.includes('✔ OK') && !line.includes('FAILED') && !line.includes(' in ') && !line.includes('ms') && line.trim() !== '')
// In ESM mode, execution order has changed - main steps complete first, then within steps continue asynchronously
// We should see the main steps, then the within setup, but the within steps get cut off due to async execution
stepsList.should.include('Scenario()')
stepsList.should.include('I small promise ')
stepsList.should.include('I small promise was finished ')
stepsList.should.include('I small yield ')
stepsList.should.include('I am small yield string await')
stepsList.should.include('Within "blabla"')
done()
})
})
it('should execute with async/await. Await is second in order', done => {
exec(`${codecept_run} --debug`, (_err, stdout) => {
// Check that the test passed by looking for success indicators
stdout.should.include('✔ OK')
const lines = stdout.match(/\S.+/g)
const withGeneratorList = grepLines(lines, 'Check within with async/await. Await is second in order', '-- FAILURES:')
// Filter out status lines to get just the step executions
const stepsList = withGeneratorList.filter(line => !line.includes('✔ OK') && !line.includes('FAILED') && !line.includes(' in ') && !line.includes('ms') && line.trim() !== '')
// In ESM mode, execution order has changed - main steps complete first, then within steps continue asynchronously
// Due to test boundary mixing, we just verify key steps are present
stepsList.should.include('Scenario()')
stepsList.should.include('I small promise ')
stepsList.should.include('I small promise was finished ')
stepsList.should.include('I small yield ')
stepsList.should.include('I am small yield string await')
stepsList.should.include('Within "blabla"')
done()
})
})
})