karma-runner / karma

Spectacular Test Runner for JavaScript
http://karma-runner.github.io
MIT License
11.96k stars 1.71k forks source link

Exits with status code 1 and does not run tests #2528

Open brentoneill opened 7 years ago

brentoneill commented 7 years ago

Expected behaviour

Tests should run as expected and open the browser window.

Actual behaviour

➜  NeXgen-RulesEngine git:(master) npm run test

> form-rules@1.0.0 test /Users/brentoneill/Desktop/NeXgen-RulesEngine
> karma start karma.config.js --no-auto-watch

ts-loader: Using typescript@1.8.10 and /Users/brentoneill/Desktop/NeXgen-RulesEngine/tsconfig.json
06 01 2017 11:10:47.012:INFO [karma]: Karma v0.13.22 server started at http://localhost:9876/
06 01 2017 11:10:47.022:INFO [launcher]: Starting browser Chrome
06 01 2017 11:10:47.814:INFO [Chrome 55.0.2883 (Mac OS X 10.11.6)]: Connected on socket /#bQUigWQLHMsCwypEAAAA with id 33535306
Chrome 55.0.2883 (Mac OS X 10.11.6): Executed 0 of 0 ERROR (0.003 secs / 0 secs)

npm ERR! Darwin 15.6.0
npm ERR! argv "/Users/brentoneill/.nvm/versions/node/v5.12.0/bin/node" "/Users/brentoneill/.nvm/versions/node/v5.12.0/bin/npm" "run" "test"
npm ERR! node v5.12.0
npm ERR! npm  v3.8.6
npm ERR! code ELIFECYCLE
npm ERR! form-rules@1.0.0 test: `karma start karma.config.js --no-auto-watch`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the form-rules@1.0.0 test script 'karma start karma.config.js --no-auto-watch'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the form-rules package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     karma start karma.config.js --no-auto-watch
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs form-rules
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls form-rules
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/brentoneill/Desktop/NeXgen-RulesEngine/npm-debug.log```

Environment Details

Steps to reproduce the behaviour

  1. Run the test command npm run test 2.Karma looks like its starting then it shows that it executes 0 of 0 tests when we have 133 in this repo.

npm debug log

0 info it worked if it ends with ok
1 verbose cli [ '/Users/brentoneill/.nvm/versions/node/v5.12.0/bin/node',
1 verbose cli   '/Users/brentoneill/.nvm/versions/node/v5.12.0/bin/npm',
1 verbose cli   'run',
1 verbose cli   'test' ]
2 info using npm@3.8.6
3 info using node@v5.12.0
4 verbose run-script [ 'pretest', 'test', 'posttest' ]
5 info lifecycle form-rules@1.0.0~pretest: form-rules@1.0.0
6 silly lifecycle form-rules@1.0.0~pretest: no script for pretest, continuing
7 info lifecycle form-rules@1.0.0~test: form-rules@1.0.0
8 verbose lifecycle form-rules@1.0.0~test: unsafe-perm in lifecycle true
9 verbose lifecycle form-rules@1.0.0~test: PATH: /Users/brentoneill/.nvm/versions/node/v5.12.0/lib/node_modules/npm/bin/node-gyp-bin:/Users/brentoneill/Desktop/NeXgen-RulesEngine/node_modules/.bin:/Users/brentoneill/.nvm/versions/node/v5.12.0/bin:/Users/brentoneill/.nvm/versions/node/v5.12.0/bin:/Users/brentoneill/.rvm/gems/ruby-2.1.0/bin:/Users/brentoneill/.rvm/gems/ruby-2.1.0@global/bin:/Users/brentoneill/.rvm/rubies/ruby-2.1.0/bin:/usr/local/heroku/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/brentoneill/apache-maven-3.3.9/bin:/Users/brentoneill/.rvm/bin
10 verbose lifecycle form-rules@1.0.0~test: CWD: /Users/brentoneill/Desktop/NeXgen-RulesEngine
11 silly lifecycle form-rules@1.0.0~test: Args: [ '-c', 'karma start karma.config.js --no-auto-watch' ]
12 silly lifecycle form-rules@1.0.0~test: Returned: code: 1  signal: null
13 info lifecycle form-rules@1.0.0~test: Failed to exec test script
14 verbose stack Error: form-rules@1.0.0 test: `karma start karma.config.js --no-auto-watch`
14 verbose stack Exit status 1
14 verbose stack     at EventEmitter.<anonymous> (/Users/brentoneill/.nvm/versions/node/v5.12.0/lib/node_modules/npm/lib/utils/lifecycle.js:239:16)
14 verbose stack     at emitTwo (events.js:100:13)
14 verbose stack     at EventEmitter.emit (events.js:185:7)
14 verbose stack     at ChildProcess.<anonymous> (/Users/brentoneill/.nvm/versions/node/v5.12.0/lib/node_modules/npm/lib/utils/spawn.js:24:14)
14 verbose stack     at emitTwo (events.js:100:13)
14 verbose stack     at ChildProcess.emit (events.js:185:7)
14 verbose stack     at maybeClose (internal/child_process.js:850:16)
14 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:215:5)
15 verbose pkgid form-rules@1.0.0
16 verbose cwd /Users/brentoneill/Desktop/NeXgen-RulesEngine
17 error Darwin 15.6.0
18 error argv "/Users/brentoneill/.nvm/versions/node/v5.12.0/bin/node" "/Users/brentoneill/.nvm/versions/node/v5.12.0/bin/npm" "run" "test"
19 error node v5.12.0
20 error npm  v3.8.6
21 error code ELIFECYCLE
22 error form-rules@1.0.0 test: `karma start karma.config.js --no-auto-watch`
22 error Exit status 1
23 error Failed at the form-rules@1.0.0 test script 'karma start karma.config.js --no-auto-watch'.
23 error Make sure you have the latest version of node.js and npm installed.
23 error If you do, this is most likely a problem with the form-rules package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error     karma start karma.config.js --no-auto-watch
23 error You can get information on how to open an issue for this project with:
23 error     npm bugs form-rules
23 error Or if that isn't available, you can get their info via:
23 error     npm owner ls form-rules
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]
wesleycho commented 7 years ago

Can you slim this down into a minimal reproduction in a repository?

If it helps, I have seen this error happen when there is a syntax error in one of my scripts. I would check to see if TypeScript isn't erroring out and the stack trace isn't being outputted. It might help to try wiring in tslint and running that to see if there are not any errors coming in there.

brentoneill commented 7 years ago

Closing as it appears the issues is with the karma-chrome-launcher plugin - tests run fine on the FireFox launcher

kirahowe commented 6 years ago

Do you have a reference to an issue or any more information about the problem with karma-chrome-launcher by any chance? I'm getting this problem, too.

ibaraness commented 6 years ago

Hi Guys. I don't know if it will solve your problem, but I came up with similar problem while running 'karma --single-run --browsers Chrome' from npm script. I would get an unclear npm error:

Chrome 61.0.3163 (Windows 10 0.0.0): Executed 0 of 0 ERROR (0.007 secs / 0 secs)

npm ERR! Windows_NT 10.0.15063 npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Users\M.S.BIT\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js" "run" "test" npm ERR! node v6.9.4 npm ERR! npm v4.1.1 npm ERR! code ELIFECYCLE npm ERR! karma_angular2@1.0.0 test: node ./node_modules/karma/bin/karma start --single-run --browsers Chrome npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the karma_angular2@1.0.0 test script 'node ./node_modules/karma/bin/karma start --single-run --browsers Chrome'. npm ERR! Make sure you have the latest version of node.js and npm installed. npm ERR! If you do, this is most likely a problem with the karma_angular2 package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR! node ./node_modules/karma/bin/karma start --single-run --browsers Chrome npm ERR! You can get information on how to open an issue for this project with: npm ERR! npm bugs karma_angular2 npm ERR! Or if that isn't available, you can get their info via: npm ERR! npm owner ls karma_angular2 npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request: npm ERR! C:\dev\angular2_karma\npm-debug.log

At the end the problem was that I didn't had any tests and the script would fail. I finally solved it by adding : failOnEmptyTestSuite: false to my karma.conf.js file, so it won't fail the script when there are no tests. Hope it will help in any way.

mistyharsh commented 6 years ago

Thank you @ibaraness. I spend two days because of this issue. I am writing my tests in TypeScript and somehow, karma is not picking up tests written in TypeScript. Now, at least I know the error. I can go further.

johnjbarton commented 6 years ago

Seems like we could have the error message reflect the flag, eg failOnEmptyTestSuite

Chrome 61.0.3163 (Windows 10 0.0.0): Executed 0 of 0 && failOnEmptyTestSuite == true: ERROR (0.007 secs / 0 secs)
prograhammer commented 6 years ago

@mistyharsh Make sure you include the mime:

mime: {
  'text/x-typescript': ['ts']
},
kentonbmax commented 6 years ago

Steps for me to improve the error occurrence: I upgrade karma to v3x and added a custom launcher in karma.config with the flags below from an example online: flags: [ '--headless', '--disable-gpu', // Without a remote debugging port, Google Chrome exits immediately. '--remote-debugging-port=9222' ]

joaodarocha commented 5 years ago

Thanks @ibaraness! I spent one entire day looking for a fix for this error, and finally found that I only had to add to my karma.conf.js: failOnEmptyTestSuite: false