-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Expand file tree
/
Copy pathe2e.spec.ts
More file actions
70 lines (55 loc) · 1.69 KB
/
Copy pathe2e.spec.ts
File metadata and controls
70 lines (55 loc) · 1.69 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
'use strict';
var ng = require('../helpers/ng');
var path = require('path');
var tmp = require('../helpers/tmp');
var conf = require('ember-cli/tests/helpers/conf');
var expect = require('chai').expect;
var child_process = require('child_process');
var treeKill = require('tree-kill');
var root = path.join(process.cwd(), 'tmp');
const ngBin = `node ${path.join(process.cwd(), 'bin', 'ng')}`;
describe('Acceptance ng e2e: ', function () {
before(function () {
this.timeout(100000);
conf.setup();
return tmp.setup('./tmp').then(function () {
process.chdir('./tmp');
})
});
after(function () {
this.timeout(100000);
conf.restore();
return tmp.teardown('./tmp');
});
it('Fails to execute outside of project', function () {
this.timeout(100000);
expect(ng(['e2e'])).to.throw;
});
it('Fails to execute without running project', function () {
this.timeout(240000);
var ngE2ePid;
var e2eProcess;
function executor(resolve, reject) {
ng(['new', 'test-project', '--skip-npm', '--skip-bower']).then(function () {
process.chdir(path.join(root, 'test-project'));
}).then(function () {
e2eProcess = child_process.exec(`${ngBin} e2e`);
ngE2ePid = e2eProcess.pid;
e2eProcess.stderr.on('data', (data) => {
reject(data);
});
e2eProcess.on('close', (code) => {
code !== 0 ? resolve() : reject('ng e2e command closed with error')
});
});
}
return new Promise(executor)
.then(() => {
if (ngE2ePid) treeKill(ngE2ePid);
})
.catch((msg) => {
if (ngE2ePid) treeKill(ngE2ePid);
throw new Error(msg);
});
});
});