-
-
Notifications
You must be signed in to change notification settings - Fork 750
Expand file tree
/
Copy pathretry_hooks_test.js
More file actions
69 lines (62 loc) · 2.44 KB
/
retry_hooks_test.js
File metadata and controls
69 lines (62 loc) · 2.44 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
import * as chai from 'chai';
chai.should();
import { expect } from 'expect';
import { exec } from 'child_process';
import { codecept_dir, codecept_run } from './consts.js';
import path from 'path';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const debug_this_test = false
const config_run_config = (config, grep, verbose = false) => `${codecept_run} ${verbose || debug_this_test ? '--verbose' : ''} --config ${codecept_dir}/configs/retryHooks/${config} ${grep ? `--grep "${grep}"` : ''}`
describe('CodeceptJS Retry Hooks', function () {
this.timeout(10000)
;['#Async ', '#Before ', '#BeforeSuite ', '#Helper '].forEach(retryHook => {
it(`run ${retryHook} config`, done => {
exec(config_run_config('codecept.conf.js', retryHook), (err, stdout) => {
debug_this_test && console.log(stdout)
expect(stdout).toContain('1 passed')
done()
})
})
})
it('run should load hook config from Before().retry()', done => {
exec(config_run_config('codecept.retry.hookconfig.conf.js', '#Async '), (err, stdout) => {
debug_this_test && console.log(stdout)
expect(stdout).toContain('1 passed')
done()
})
})
;['#Before ', '#BeforeSuite '].forEach(retryHook => {
it(`should ${retryHook} set hook retries from global config`, done => {
exec(config_run_config('codecept.retry.obj.conf.js', retryHook), (err, stdout) => {
debug_this_test && console.log(stdout)
expect(stdout).toContain('1 passed')
done()
})
})
})
it('should finish if retry has not happened', done => {
exec(config_run_config('codecept.conf.js', '#FailBefore '), (err, stdout) => {
debug_this_test && console.log(stdout)
expect(stdout).toContain('-- FAILURES')
expect(stdout).toContain('not works')
expect(stdout).toContain('1) Fail #FailBefore hook')
done()
})
})
it('should set global retry', done => {
exec(config_run_config('codecept.retry.global.conf.js', '#globalRetry'), (err, stdout) => {
debug_this_test && console.log(stdout)
expect(stdout).toContain('1 passed')
done()
})
})
it('should set global scenario retry', done => {
exec(config_run_config('codecept.retry.global.scenario.conf.js', '#globalScenarioRetry'), (err, stdout) => {
debug_this_test && console.log(stdout)
expect(stdout).toContain('1 passed')
done()
})
})
})