-
-
Notifications
You must be signed in to change notification settings - Fork 751
Expand file tree
/
Copy pathstep-sections_test.js
More file actions
76 lines (64 loc) · 2.73 KB
/
step-sections_test.js
File metadata and controls
76 lines (64 loc) · 2.73 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
import * as chai from 'chai'
chai.should()
import { expect } from 'expect'
import { exec } from 'child_process'
import path from 'path'
import { codecept_dir, codecept_run } from './consts.js'
import debugFactory from 'debug'
const debug = debugFactory('codeceptjs:tests')
import { fileURLToPath } from 'url'
const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)
const config_run_config = (config, grep) => `${codecept_run} --steps --config ${codecept_dir}/configs/step-sections/${config} ${grep ? `--grep "${grep}"` : ''}`
describe('CodeceptJS step-sections', function () {
this.timeout(10000)
it('should run step-sections test', done => {
exec(config_run_config('codecept.conf.js', 'basic step-sections'), (err, stdout) => {
debug(stdout)
expect(stdout).toContain('OK')
expect(stdout).toContain('User Journey')
expect(stdout).toContain('Nothing to say')
// Check for the step structure (allowing for timing info in between)
expect(stdout).toContain('I am in path "."')
expect(stdout).toContain('User Journey')
expect(stdout).toContain('I act "Hello, World!"')
expect(stdout).toContain('I act "Nothing to say"')
// Verify the indentation structure for sections
expect(stdout).toMatch(/\s+User Journey/)
expect(stdout).toMatch(/\s+I act "Hello, World!"/)
expect(err).toBeFalsy()
done()
})
})
it('should run step-sections with page objects', done => {
exec(config_run_config('codecept.conf.js', 'sections and page objects'), (err, stdout) => {
debug(stdout)
expect(stdout).toContain('OK')
expect(stdout).toContain('User Journey')
// Check for the step structure (allowing for timing info in between)
expect(stdout).toContain('User Journey')
expect(stdout).toContain('On userPage: act on page')
expect(stdout).toContain('I act "actOnPage"')
expect(stdout).toContain('I act "see on this page"')
expect(stdout).toContain('I act "One more step"')
expect(stdout).toContain('I act "Nothing to say"')
// Verify the indentation structure for sections and nested steps
expect(stdout).toMatch(/\s+User Journey/)
expect(stdout).toMatch(/\s+On userPage: act on page/)
expect(stdout).toMatch(/\s+I act "actOnPage"/)
expect(err).toBeFalsy()
done()
})
})
it('should run hidden step-sections', done => {
exec(config_run_config('codecept.conf.js', 'hidden step-sections'), (err, stdout) => {
debug(stdout)
expect(stdout).toContain('OK')
expect(stdout).toContain('User Journey')
expect(stdout).not.toContain('actOnPage')
expect(stdout).not.toContain('One more step')
expect(err).toBeFalsy()
done()
})
})
})