4

This seems like a project setup problem in someway. This was working previously. I don't have the knowledge that these error messages help me to start. Does anyone have some advice on where to start diagnosing the problem?

21 05 2017 07:42:55.094:WARN [karma]: No captured browser, open http://localhost:9876/
21 05 2017 07:42:55.110:INFO [karma]: Karma v1.4.1 server started at http://0.0.0.0:9876/
21 05 2017 07:42:55.110:INFO [launcher]: Launching browser Chrome with unlimited concurrency
21 05 2017 07:42:55.118:INFO [launcher]: Starting browser Chrome                                                                                                                                                                                                        ERROR in /Users/jgreenaw/WebstormProjects/legalcoveapp/node_modules/@angular/core/src/testability/testability.d.ts (41,33): Cannot find name 'Node'.

ERROR in /Users/jgreenaw/WebstormProjects/legalcoveapp/node_modules/@angular/forms/src/directives/ng_form.d.ts (69,22): Cannot find name 'Event'.

ERROR in /Users/jgreenaw/WebstormProjects/legalcoveapp/node_modules/@angular/forms/src/directives/reactive_directives/form_group_directive.d.ts (74,22): Cannot find name 'Event'.

ERROR in /Users/jgreenaw/WebstormProjects/legalcoveapp/node_modules/@ng-bootstrap/ng-bootstrap/rating/rating.d.ts (58,26): Cannot find name 'KeyboardEvent'.

ERROR in /Users/jgreenaw/WebstormProjects/legalcoveapp/node_modules/@ng-bootstrap/ng-bootstrap/typeahead/typeahead.d.ts (81,26): Cannot find name 'KeyboardEvent'.
Pompey Magnus
  • 2,191
  • 5
  • 27
  • 40
  • Can you find an earlier commit that does work? – Matthew Daly May 21 '17 at 11:52
  • good question, i reverted to a previous commit 5 days ago labeled "got tests to work", and it failed with same error. Something to note, i get the same problem in my cloud9 environment, but there i would expect this. – Pompey Magnus May 21 '17 at 12:14
  • Maybe delete your node_modules/ and run npm install again with the old commit? This sort of thing is why I like continuous integration as it weeds out environment-specific problems. – Matthew Daly May 21 '17 at 12:19

3 Answers3

5

After upgrading my Angular lib versions, my Karma tests too started to fail which led me to the this question. After verifying the @angular/cli versions, now 1.1.2, match between global and the local project the following may also be required:

Update your src/tsconfig.spec.json by adding "dom" to the lib array:

"lib": ["es2016", "dom"],
Heather92065
  • 7,333
  • 6
  • 31
  • 39
  • +1 Fixed for me. can't believe, the problem was that simple. Also have to say that angular cli error logs are horrible and fearsome. I fled from them wandering looking for other options like web-pack and typescript and wasted two days. – Aqeel Ashiq Oct 23 '17 at 09:39
0

I was able to move forward past the problem, but not identify the root cause by doing the following.

  • sync angular/cli project and global versions to latest: 1.0.4
  • rm node_modules which I had done before, but reading this. I was missing npm cache clean
  • npm install

Thanks @MatthewDaly for the useful suggestions and questions.

Pompey Magnus
  • 2,191
  • 5
  • 27
  • 40
0

If running karma test from your IDE (for example, IntelliJ IDEA) and your solution doesn't build/has lint errors, karma seems to not connect and just hang.

Run your tests with something like ng test and get that working before running from your IDE.

Ian
  • 2,898
  • 1
  • 27
  • 29