forked from ovh/manager
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: add webpack-cypress script to facilitate e2e tests
- Loading branch information
jleveugle
committed
Dec 18, 2018
1 parent
9cdabab
commit 59ca05a
Showing
3 changed files
with
27 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const execa = require('execa'); | ||
const tcpPortUsed = require('tcp-port-used'); | ||
const fp = require('find-free-port'); | ||
|
||
fp(3000, (err, port) => { | ||
const webpackApp = execa.shell(`yarn start --port ${port}`); | ||
webpackApp.stdout.pipe(process.stdout); | ||
|
||
tcpPortUsed.waitUntilUsed(port, 500, 1000 * 60 * 2) | ||
.then(() => { | ||
const cypressShell = execa.shell(`cypress run --config baseUrl=http://localhost:${port}`); | ||
cypressShell.stdout.pipe(process.stdout); | ||
return cypressShell; | ||
}) | ||
.then(() => execa.shell(`kill -9 $(lsof -i:${port} -t)`)) | ||
.then(() => process.exit(0)) | ||
.catch((err) => { console.error(err); process.exit(1); }); // eslint-disable-line | ||
}); |