Exit with error if --watch is used in CI
See original GitHub issue(Rather than ignoring --watch
we’ve decided to exit with an error instead: https://github.com/avajs/ava/issues/1186#issuecomment-274246060 — @novemberborn)
Description
This is a feature request. Skip ‘–watch’ arg if isCi
Since we have known our test running on CI server. Ava should more clever to ignore --watch
arg.
Config
Copy the relevant section from package.json
:
{
"scripts": {
"test": "ava -w"
}
}
Now I write my test command like this:
{
"scripts": {
"test": "[ -z $CI ] && (ava -w); [ $CI ] && (ava)"
}
}
Issue Analytics
- State:
- Created 7 years ago
- Comments:14 (14 by maintainers)
Top Results From Across the Web
Linux CLI watch switch -e, --errexit unexpected exit with ...
The problem is that watch terminates if the output of command does not fit into the CLI window.
Read more >Exit (light) Codes - GitHub Pages
Continuous Integration / Continuous Development (CI/CD) ... Exit codes are used to identify if a command or script executed with errors or not....
Read more >Process will exit when watch mode is on · Issue #730
Is the error message Cannot use "watch" with "serve" ? It is an intentional limitation that you can't use both watch and serve...
Read more >Make it possible to control build status using exit codes - GitLab
The workaround I'm now using: in the following pipeline stages, test for the condition where you want to skip, and exit 0 early....
Read more >Exit Code 137 - Out of Memory
Exit Code 137 - Out of memory. This is a Linux error code which you may see on CircleCI when your container runs...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
To summarize the discussion, the solution would be to raise an error (exiting with 1 to allow stop the process in CI) with the following explanatory message :
AVA will not run with the --watch (-w) option in CI, because CI processes should terminate, and with the --watch option, AVA will never terminate.
Is that the right solution?
I can do the PR if you want (Code, test and explanation in docs)
Yes. “Skipping” watching, with a warning, seems reasonable. But, if anyone is running with
-w
in CI it most likely means that histest
script hasava -w
. Shouldn’t we “educate” by not letting that pass, and instead provide a kind message?