-
Notifications
You must be signed in to change notification settings - Fork 16
/
e2e-script.js
56 lines (49 loc) · 1.35 KB
/
e2e-script.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 concurrently = require('concurrently')
const path = require('path')
const fs = require('fs')
const { execSync } = require('child_process')
const cdnPath = path.resolve(__dirname, './federation-cdn-mock')
const cdnAssetsPath = path.resolve(__dirname, './federation-cdn-mock/dist')
try {
fs.statSync(cdnAssetsPath)
} catch (error) {
// create server asset dir
fs.mkdirSync(cdnAssetsPath)
}
// install private package
execSync('npm install', { cwd: cdnPath, stdio: 'inherit'})
// ensure the deps exist before we start the servers
execSync('npm run build -c webpack.config.js', { cwd: cdnPath, stdio: 'inherit'})
const {result, commands} = concurrently(
[{
name: 'cdn-server',
cwd: cdnPath,
command: 'npm run serve',
},
{
cwd: __dirname,
name: 'test-app',
command: 'npx nx run test-app:serve',
}, {
cwd: __dirname,
name: 'e2e',
command: 'npx wait-on http://localhost:4200 http://127.0.0.1:8001 && npx nx run test-app-e2e:e2e --skipNxCache',
}],
{
successCondition: 'e2e',
killOthers: ['success', 'failure'],
}
)
result.catch((e) => {
const e2eJob = e.find(({ command: {name} }) => name ==='e2e')
if(!e2eJob) {
console.error('E2E tests job not found')
process.exit(1)
}
if(e2eJob.exitCode === 0) {
process.exit(0)
} else {
console.error('E2E tests failed')
process.exit(1)
}
})