Skip to content

Commit

Permalink
build: add webpack-cypress script to facilitate e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jleveugle committed Dec 18, 2018
1 parent 9cdabab commit 59ca05a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
3 changes: 2 additions & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"lerna": "3.4.3",
"packages": [
"packages/manager/*"
"packages/manager/*",
"packages/manager/**/app"
],
"npmClient": "yarn",
"useWorkspaces": true,
Expand Down
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"description": "OVH Control Panel also known as Manager",
"license": "BSD-3-Clause",
"workspaces": [
"packages/manager/*"
"packages/manager/*",
"packages/manager/**/app"
],
"scripts": {
"build": "lerna run build --stream",
Expand All @@ -19,7 +20,8 @@
"lint:md": "remark -qf .",
"packages:publish": "node ./scripts/publish",
"start": "lerna run dev --stream --parallel",
"test": "yarn lint",
"test": "yarn lint && yarn run test:e2e",
"test:e2e": "lerna run test:e2e --stream",
"version": "conventional-changelog -p angular -i CHANGELOG.md -s && git add CHANGELOG.md",
"release": "node ./scripts/release"
},
Expand All @@ -35,6 +37,7 @@
"eslint-config-airbnb-base": "^13.1.0",
"eslint-import-resolver-lerna": "^1.0.0",
"execa": "^1.0.0",
"find-free-port": "^2.0.0",
"htmlhint": "^0.10.0",
"husky": "^1.0.0",
"lerna": "^3.4.3",
Expand All @@ -47,7 +50,8 @@
"remark-preset-lint-recommended": "^3.0.2",
"semver": "^5.6.0",
"stylelint": "^9.5.0",
"stylelint-config-standard": "^18.2.0"
"stylelint-config-standard": "^18.2.0",
"tcp-port-used": "^1.0.1"
},
"engines": {
"node": ">=8.11"
Expand Down
18 changes: 18 additions & 0 deletions scripts/webpack-cypress.js
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
});

0 comments on commit 59ca05a

Please sign in to comment.