-
-
Notifications
You must be signed in to change notification settings - Fork 737
/
Copy pathsession_test.js
70 lines (61 loc) · 2.1 KB
/
session_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
63
64
65
66
67
68
69
70
const path = require('path');
const exec = require('child_process').exec;
const { grepLines } = require('../../lib/utils').test;
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.session.json `;
describe('CodeceptJS session', function () {
this.timeout(40000);
before(() => {
global.codecept_dir = path.join(__dirname, '/../data/sandbox');
});
it('should run with 3 sessions', (done) => {
exec(`${codecept_run} --steps --grep "@1"`, (err, stdout, stderr) => {
const lines = stdout.match(/\S.+/g);
const list = grepLines(lines, 'basic session @1');
list.pop();
testStatus = list.pop();
testStatus.should.include('OK');
list.should.eql([
'I do "writing"',
'davert: I do "reading"',
'I do "playing"',
'john: I do "crying"',
'davert: I do "smiling"',
'I do "laughing"',
'mike: I do "spying"',
'john: I do "lying"',
'I do "waving"',
], 'check steps execution order');
done();
});
});
it('should run session defined before executing', (done) => {
exec(`${codecept_run} --steps --grep "@2"`, (err, stdout, stderr) => {
const lines = stdout.match(/\S.+/g);
const list = grepLines(lines, 'session defined not used @2');
list.pop();
testStatus = list.pop();
testStatus.should.include('OK');
list.should.eql([
'I do "writing"',
'I do "playing"',
'john: I do "crying"',
'davert: I do "smiling"',
'I do "laughing"',
'davert: I do "singing"',
'I do "waving"',
], 'check steps execution order');
done();
});
});
it('should run all session tests', (done) => {
exec(`${codecept_run} --steps`, (err, stdout, stderr) => {
const lines = stdout.match(/\S.+/g);
const testStatus = lines.pop();
testStatus.should.include('passed');
testStatus.should.not.include(' 1 ', 'more than 1 test expected');
done();
});
});
});