-
-
Notifications
You must be signed in to change notification settings - Fork 737
/
Copy pathplugin_test.js
62 lines (55 loc) · 2.19 KB
/
plugin_test.js
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
const path = require('path')
const { exec } = require('child_process')
const { expect } = require('expect')
const runner = path.join(__dirname, '../../bin/codecept.js')
const codecept_dir = path.join(__dirname, '../acceptance')
const codecept_run = `${runner} run`
const config_run_config = (config, grep) =>
`${codecept_run} --config ${codecept_dir}/${config} ${grep ? `--grep "${grep}"` : ''}`
describe('CodeceptJS plugin', function () {
this.timeout(30000)
before(() => {
process.chdir(codecept_dir)
})
it('should retry the await/non await steps', (done) => {
exec(`${config_run_config('codecept.Playwright.retryTo.js', '@plugin')} --verbose`, (err, stdout) => {
const lines = stdout.split('\n')
expect(lines).toEqual(expect.arrayContaining([expect.stringContaining('... Retrying')]))
expect(err).toBeFalsy()
done()
})
})
it('should failed before the retryTo instruction', (done) => {
exec(`${config_run_config('codecept.Playwright.retryTo.js', 'Should be succeed')} --verbose`, (err, stdout) => {
expect(stdout).toContain('locator.waitFor: Timeout 1000ms exceeded.')
expect(stdout).toContain('[1] Error | Error: element (.nothing) still not visible after 1 sec')
expect(err).toBeTruthy()
done()
})
})
it('should generate the coverage report', (done) => {
exec(`${config_run_config('codecept.Playwright.coverage.js', '@coverage')} --debug`, (err, stdout) => {
const lines = stdout.split('\n')
expect(lines).toEqual(
expect.arrayContaining([
expect.stringContaining('writing output/coverage'),
expect.stringContaining('generated coverage reports:'),
expect.stringContaining('output/coverage/index.html'),
]),
)
expect(err).toBeFalsy()
done()
})
})
it('should retry to failure', (done) => {
exec(
`${config_run_config('codecept.Playwright.retryTo.js', 'Should fail after reached max retries')} --verbose`,
(err, stdout) => {
const lines = stdout.split('\n')
expect(lines).toEqual(expect.arrayContaining([expect.stringContaining('Custom pluginRetryTo Error')]))
expect(err).toBeTruthy()
done()
},
)
})
})