Please provide us with the following information:
Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?)
Windows 7
Please run
ng --version. If there's nothing outputted, please run in a Terminal:node --versionand paste the result here:
angular-cli: 1.0.0-beta.22-1
node: 6.9.1
os: win32 x64
Was this an app that wasn't created using the CLI? What change did you do on your code? etc.
- create project using
ng new- change
autoWatchtofalseandsingleRuntotrueinkarma.conf.js- run
ng test
expected: tests are run once and the browser is closed
actual: tests do not run and the browser stays open (when autoWatch is true the tests are run, but browser stays open nonetheless)
Normally this include a stack trace and some more information.
nothing happens (no error message or stack trace)
Such config was last running fine on [email protected].
Running ng test --watch false --single-run true works as expected.
Thanks! We'll be in touch soon.
seconded
Currently we have defaults for --single-run and --watch on the test command that overwrite the ones in Karma config. We really shouldn't overwrite them if the user doesn't use the flags.
ng test --watch false --single-run true
npm run ng test --watch false --single-run true
node v7.7.2, npm v3.10.7, @angular/cli v1.0.0-rc.1
@sadgit Yes, because all the ---options go to npm and not to ng.
npm run -- ng test --watch false --single-run true should work.
Added script to package.json
scripts": {... , "ci-test": "ng test --watch false --single-run true" }
Then npm run ci-test works too
Closing as outdated. If this is still a problem, please let me know.
@filipesilva
Yes the problem still exists.
ng --version
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ â–³ \ | '_ \ / _| | | | |/ _ | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ __| |_|__, |__,_|_|__,_|_| ____|_____|___|
|___/
@angular/cli: 1.0.0
node: 8.1.2
os: darwin x64
@angular/common: 4.2.2
@angular/compiler: 4.2.2
@angular/core: 4.2.2
@angular/forms: 4.2.2
@angular/http: 4.2.2
@angular/platform-browser: 4.2.2
@angular/platform-browser-dynamic: 4.2.2
@angular/router: 4.2.2
@angular/cli: 1.0.0
@angular/compiler-cli: 4.2.2
setting singleRun: true in karma.config does not exit after execution.
works only through command line
ng test --single-run true
https://karma-runner.github.io/latest/intro/installation.html
Installation says Karma doesn't work with node 8.1.2 - is that still the case? Maybe that's why mrj04 still has the issue. It's halted my foray into using Karma for now too.
Update 1: (See update 2 below before committing to this) The Angular documentation mentions nvm is recommended. It allows you to swap between node versions easily. That's what I was hesitant about. I installed node via brew and wasn't sure about whether nvm would step on brew's toes. But from looking at these links it seems fine.
https://apple.stackexchange.com/questions/171530/how-do-i-downgrade-node-or-install-a-specific-previous-version-using-homebrew
https://stackoverflow.com/questions/28017374/what-is-the-suggested-way-to-install-brew-node-js-io-js-nvm-npm-on-os-x
http://dev.topheman.com/install-nvm-with-homebrew-to-use-multiple-versions-of-node-and-iojs-easily/
https://davidwalsh.name/nvm
https://github.com/creationix/nvm#usage
Karma also has a pertinent comment in the FAQ
https://karma-runner.github.io/latest/intro/faq.html - it works with the LTS versions.
https://nodejs.org/en/download/ - indicates 6.11.0 for Mac at the time of writing this comment.
https://github.com/nodejs/LTS/blob/master/README.md
This is roughly what I did:
brew update
brew install nvm
mkdir ~/.nvm
Modified startup
.profile
export NVM_DIR="$HOME/.nvm"
.bash_profile
source ~/.profile
source $(brew --prefix nvm)/nvm.sh
[[ -r $NVM_DIR/bash_completion ]] && . $NVM_DIR/bash_completion
source ~/.bashrc
Then ran:
brew uninstall node
nvm install node
nvm version-remote
nvm install v6.11.0
node -v shows v6.11.0
nvm use v8.1.2
node -v shows v8.1.2
When you use
nvm install node
nvm install v6.11.0
it places the versions of node into the ~/nvm/versions/node folder
Hence the reason I did brew uninstall node - that removed old version not under nvm control from
something like usr/local/opt
UPDATE 2:
Per here:
https://github.com/creationix/nvm/tree/v0.33.2#installation
(search on "brew")
Homebrew installation is not supported. If you have issues with homebrew-installed nvm, please brew uninstall it, and install it using the instructions below, before filing an issue.
On the surface for me things seem ok. I've not had issues as yet but will repost if things run awry...
I still get problems with --single-run option.
angular-cli version: 1.5.6
Angular 5.1.3
OS: win32 x64
Anytime the --single-run flag is added the following error message is displayed.
ng test --code-coverage --browsers ChromeHeadless --reporters html --watch false --single-run true
returns at end of test run
02 02 2018 13:53:53.395:WARN [launcher]: ChromeHeadless was not killed in 2000 ms, sending SIGKILL.
Output is generated but if I want to run the unit tests with coverage as part of a build that will not work because NPM exits on the error. If I don't use the --single-run flag on the ng test script it never stops.
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
_This action has been performed automatically by a bot._
Most helpful comment
@sadgit Yes, because all the
---options go to npm and not to ng.npm run -- ng test --watch false --single-run trueshould work.See http://unix.stackexchange.com/a/11382