forked from nightwatchjs/nightwatch
/
testRunnerEndSessionOnFail.js
56 lines (42 loc) · 1.36 KB
/
testRunnerEndSessionOnFail.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
const path = require('path');
const assert = require('assert');
const nock = require('nock');
const nocks = require('../../lib/nocks');
const common = require('../../common.js');
const CommandGlobals = require('../../lib/globals/commands.js');
const {settings} = common;
const {runTests} = common.require('index.js');
describe('test runner with end_session_on_fail flag', function() {
before(function(done) {
nocks.enable().cleanAll();
CommandGlobals.beforeEach.call(this, done);
});
after(function(done) {
nocks.disable();
CommandGlobals.afterEach.call(this, done);
});
it('session is not ended with end_on_sessiion_fail: false', function() {
let endSessionCalled = false;
const testFile = path.join(__dirname, '../../sampletests/withfailures/sample.js');
nocks.createSession()
.url()
.elementNotFound('#weblogin');
nock('http://localhost:10195')
.delete('/wd/hub/session/1352110219202')
.reply(204, ()=> {
endSessionCalled = true;
return '';
});
return runTests(testFile, settings({
enable_fail_fast: true,
end_session_on_fail: false,
globals: {
waitForConditionPollInterval: 5,
waitForConditionTimeout: 5,
retryAssertionTimeout: 1
}
})).catch(_ => {
assert.strictEqual(endSessionCalled, false);
});
});
});