2

I have installed the ng-fullstack generator and selected the options for Angular 2 and Node. Everything plays nicely... apart from the tests. When I try to execute the tests they fail. Any search I have done tells me what a downgrade of zone.js to 0.6.2 will solve the problem, however, I cannot downgrade as Angular 2 requires a later version of Zone.js, so I'm a bit stuck:

@angular/core@2.4.2 requires a peer of zone.js@^0.7.2 but none was installed.

Points to note, when I first install the generator, it installs a lower version of zone.js - a version that would be compatible with getting the tests to work (according to my Googling). If I execute the tests with zone.js@^0.7.2 I see this error:

Chrome 55.0.2883 (Mac OS X 10.12.2) ERROR
  Uncaught Error: Missing: SyncTestZoneSpec
  at node_modules/zone.js/dist/jasmine-patch.js:43

10 01 2017 15:34:26.123:WARN [web-server]: 404: /base/node_modules/@angular/core/testing.js
10 01 2017 15:34:26.126:WARN [web-server]: 404: /base/node_modules/@angular/platform-browser-dynamic/testing.js

[15:34:26] 'client.unit_test' errored after 2.47 s

Does anyone have any suggestions of how I can get my Jasmine tests to work? I'm a bit stumped with this one. Thanks in advance!

Creights
  • 907
  • 1
  • 12
  • 25

1 Answers1

0

you should load all zone related files in your test config file.

for example, if you use karma, you should include

  'node_modules/zone.js/dist/zone.js',
  'node_modules/zone.js/dist/long-stack-trace-zone.js',
  'node_modules/zone.js/dist/proxy.js',
  'node_modules/zone.js/dist/sync-test.js',
  'node_modules/zone.js/dist/jasmine-patch.js',
  'node_modules/zone.js/dist/async-test.js',
  'node_modules/zone.js/dist/fake-async-test.js'

in karma.conf.js files block.

if you use node, you should also have a polyfill file which define all the files will be loaded before test begin, so put the above files in that polyfill file.

jiali passion
  • 1,691
  • 1
  • 14
  • 19