Angular2 testing when receiving a test zone Zone undefined Error

I worked on the Angular tutorial https://angular.io/docs/ts/latest/guide/testing.html to create my first unit tests. I can make everything work until I get the TestBed example. When I add TestBed to the mix, I get the message "Uncaught ReferenceError: Zone is not defined".

In my spectral package zone, I declared and initialized the Testbed environment.

Spec bundle

Error.stackTraceLimit = Infinity;

require('phantomjs-polyfill');

require('core-js/es6');
require('core-js/es7/reflect');

// Typescript emit helpers polyfill
require('ts-helpers');

// DO NOT REORDER: Dependency order needs to be strictly followed
require('zone.js/dist/zone');
require('zone.js/dist/long-stack-trace-zone');
require('zone.js/dist/async-test');
require('zone.js/dist/fake-async-test');
require('zone.js/dist/sync-test');
require('zone.js/dist/proxy');
require('zone.js/dist/jasmine-patch');

// RxJS
require('rxjs/Rx');

var testing = require('@angular/core/testing');
var browser = require('@angular/platform-browser-dynamic/testing');

testing.TestBed.initTestEnvironment(
    browser.BrowserDynamicTestingModule,
    browser.platformBrowserDynamicTesting()
);

Object.assign(global, testing);

window.__karma__ && require('./karma-require');

Test file

import { ComponentFixture, TestBed } from '@angular/core/testing';   
import { SomeComponent } from './some.component';

let fixture: ComponentFixture<SomeComponent>;

describe('Orders Component', () => {

    let ordersComponentStub: SomeComponent;

    beforeEach(() => {
        TestBed.configureTestingModule({
            declarations: [SomeComponent]

        });
    });

});

+4
source share
1 answer

, . Wallaby.js, module.exports

{pattern: 'node_modules/zone.js/dist/zone.js', included: true, watched: true}

- , .

+1

Source: https://habr.com/ru/post/1663168/


All Articles