question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ng test not working after upgrade to 6.0.0

See original GitHub issue

After upgrading the cli the unit tests doesn’t start anymore. Previous behaviour was that the unit tests were found and executed. Now it does not find the unit tests and says 0 of 0 executed.

Versions

Angular CLI: 6.0.0-rc.6
Node: 9.7.1
OS: win32 x64
Angular: 5.2.2
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, platform-server, router
... service-worker

Repro steps

  1. Upgrade to latest cli
  2. ng test

Observed behavior

27 04 2018 14:59:35.185:INFO [karma]: Karma v1.7.1 server started at http://0.0.0.0:9876/
27 04 2018 14:59:35.191:INFO [launcher]: Launching browser Chrome with unlimited concurrency
27 04 2018 14:59:35.201:INFO [launcher]: Starting browser Chrome                                                                                                                                                                                                                      27 04 2018 15:00:26.221:INFO [Chrome 66.0.3359 (Windows 10 0.0.0)]: Connected on socket _q17vZKEaK6MoqgCAAAA with id 70169079
Chrome 66.0.3359 (Windows 10 0.0.0): Executed 0 of 0 ERROR (0.016 secs / 0 secs)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! myproj-web@0.0.1 test: `ng test`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the myproj-web@0.0.1 test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\myuser\AppData\Roaming\npm-cache\_logs\2018-04-27T13_00_28_789Z-debug.log
10 silly lifecycle myproj-web@0.0.1~test: Args: [ '/d /s /c', 'ng test' ]
11 silly lifecycle myproj-web@0.0.1~test: Returned: code: 1  signal: null
12 info lifecycle myproj-web@0.0.1~test: Failed to exec test script
13 verbose stack Error: myproj-web@0.0.1 test: `ng test`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:285:16)
13 verbose stack     at EventEmitter.emit (events.js:127:13)
13 verbose stack     at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:127:13)
13 verbose stack     at maybeClose (internal/child_process.js:936:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:220:5)
14 verbose pkgid myproj-web@0.0.1
15 verbose cwd C:\Users\myuser\myproj\myproj-web
16 verbose Windows_NT 10.0.16299
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "test"
18 verbose node v9.7.1
19 verbose npm  v5.6.0
20 error code ELIFECYCLE
21 error errno 1
22 error myproj-web@0.0.1 test: `ng test`
22 error Exit status 1
23 error Failed at the myproj-web@0.0.1 test script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:16
  • Comments:42 (4 by maintainers)

github_iconTop GitHub Comments

12reactions
kirstenOttingcommented, May 7, 2018

I just ran into this as well (Executed 0 of 0 ERROR) after upgrading to Angular 6 on a project where tests previously ran successfully. I compared the test.ts file in my project versus a new project generated with the Angular 6 CLI, and noticed a lot of additional imports (import 'core-js/es7/reflect', import 'zone.js/dist/jasmine-patch'), etc in my project. I replaced these with:

import 'zone.js/dist/zone-testing';

and my tests started executing again. It definitely seems like an error message is getting swallowed somewhere.

7reactions
pshieldscommented, May 4, 2018

I’ve done some more investigation. My Karma entrypoint file (which I had renamed from src/test.ts to ui/main.karma.ts; all of my .ts files live in ui rather than src) does not seem to be getting executed in the way I’d expect: none of the console.error statements I place in that file ever show up in the console or terminal output (they do show up in the terminal output if I do the same thing in a clean ng new project.)

I confirmed that my main.karma.ts file is correctly referenced from the angular.json test/main option, and I confirmed that compilation fails if I change the “main” attribute to point to a nonexistent filename.

I confirmed that my *.spec.ts files are detected and included by Karma. The generated _karma_webpack_/main.js file available when running Karma contains a var map = {...} line section which maps my spec files to their workspace-relative paths, and the tests themselves show up in that file.

My suspicion is still that something is going wrong with the execution of my Karma main entrypoint file, since like I mentioned, any console.error or other logging statements I add to that file are not showing up in my terminal output. However, that file is very simple and is identical to the test.ts provided out-of-the-box by Angular CLI, so I’m still not sure what the issue is.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ng test not working after upgrade to Karma 2.0.0
There is no console output. I've tried both Chrome and ChromeHeadless for the browser but have run out of ideas. Any help would...
Read more >
Changelog - Cypress Documentation
Fixed an issue with Angular Component Testing where urls within SASS/SCSS files were not being correctly resolved which could result in incomplete styling....
Read more >
jasmine an error was thrown in afterall - You.com
I have an Angular 5 project running karma/jasmine. Unfortunately the tests stopped working after upgrading from 2.99.0 to 3.1.0 with this ambiguous error....
Read more >
What's new in Angular CLI 6.0? - Ninja Squad
The ng update command has been introduced in 1.7 but was a glorified npm install . With this release, it starts to express...
Read more >
karma-users - Google Groups
Asynchronous UT could not run normal after upgrade to the latest version @6.3.4. ... Hi All, When I run ng test I am...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found