-
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.
chore: refactor cypress startup to js script
because npm does not support command substitution on windows ref https://github.com/kentcdodds/cross-env/issues/192\#issuecomment-513341729
- Loading branch information
Showing
3 changed files
with
52 additions
and
240 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,46 @@ | ||
#!/usr/bin/env node | ||
|
||
const getPort = require('get-port'); | ||
const concurrently = require('concurrently'); | ||
|
||
(async () => { | ||
const PORT = await getPort({ port: 8765 }); | ||
const CYPRESS_BASE_URL = `http://localhost:${PORT}`; | ||
|
||
return concurrently( | ||
[ | ||
{ | ||
name: 'app', | ||
command: 'npx --no-install react-scripts start', | ||
env: { | ||
BROWSER: 'none', | ||
PORT, | ||
REACT_APP_ENV: 'test', | ||
...process.env, | ||
}, | ||
}, | ||
{ | ||
name: 'cypress', | ||
command: `npx --no-install wait-on ${CYPRESS_BASE_URL} && npx --no-install cypress open`, | ||
env: { | ||
CYPRESS_BASE_URL, | ||
...process.env, | ||
}, | ||
}, | ||
], | ||
{ | ||
killOthers: ['failure', 'success'], | ||
}, | ||
); | ||
})().catch((err) => { | ||
if ( | ||
Array.isArray(err) && | ||
!err.some(({ exitCode }) => ![0, 'SIGTERM'].includes(exitCode)) | ||
) { | ||
process.exit(0); | ||
return; | ||
} | ||
|
||
console.error(err); | ||
process.exit(err.exitCode || 1); | ||
}); |