25

I have created a new Angular 5 project using Angular cli. When I run the default test, I get the following error:

Error: Expected to be running in 'ProxyZone', but it was not found.
at Function.webpackJsonp.../../../../zone.js/dist/proxy.js.ProxyZoneSpec.assertPresent (http://localhost:9876/_karma_webpack_/webpack:/home/sukumar/workspace/bizAnalyst/partnerportal/node_modules/zone.js/dist/proxy.js:38:1)

How to rectify this issue?

P.S.: Angular version: 5.2.1

suku
  • 10,507
  • 16
  • 75
  • 120
  • What does your "files" array look like in your karma.conf.js file? It sounds like you're missing a reference to 'node_modules/zone.js/dist/jasmine-patch.js' – I. Buchan Mar 16 '18 at 21:09

2 Answers2

70

I encountered this error message when I accidentally wrote fakeAsync into the wrong line:

WRONG:

describe('My Test', fakeAsync(() => {
  it('should work', () => {

RIGHT:

describe('My Test', () => {
  it('should work', fakeAsync(() => {
bgerth
  • 1,256
  • 1
  • 12
  • 19
1

Might possibly in some cases be caused by reduce_vars on uglifyjs... in our case with Angular 6 and Webpack 4 (and uglifyjs-webpack-plugin 2.0.1).

Unsure what other contributing factors there might be, just something a colleague found out when trying to narrow a similiar problem down when upgrading to webpack4.

Jouni S.
  • 11
  • 2