Testing Nativescript with Testbed not working

For the project that we are currently running using a native script with angular2, unit testing is important to us. So I first tried to implement some simple groceries for this example, just to hang them. Very simple tests, such as testing, if email-adres checking is fine and doesn't work very much for implementation. As soon as I started with a complex test, I get errors only after Testbed is involved.

Here is the simplest implementation I have with Testbed:

import "reflect-metadata";
import 'nativescript-angular/zone.js/dist/zone-nativescript';
import {TestBed} from '@angular/core/testing';
import { UserService } from "../../../shared/user/user.service";

declare var describe: any;
declare var expect: any;
declare var it: any;
declare var beforeEach: any;

describe('UserService', () => {
    beforeEach(() => {
        TestBed.configureTestingModule({
            providers: [UserService]
        });
    }); 

    it("just testing", () => {
        console.log('hier');
        expect(false).toBe(false);
    });
});

And here is the error that I get as soon as I run it:

sampleGroceries[66839]: CONSOLE LOG file:///app/tests/shared/user/user.service.spec.js:13:20: hier
NativeScript / 10.0 (10.0; iPhone) A suite contains spec with an expectation FAILED
TypeError: undefined is not an object (evaluating 'ProxyZoneSpec.assertPresent') in file:///app/tns_modules/@angular/core/testing/../bundles/core-testing.umd.js (line 385)
resetFakeAsyncZone@file:///app/tns_modules/@angular/core/testing/../bundles/core-testing.umd.js:385:22
file:///app/tns_modules/@angular/core/testing/../bundles/core-testing.umd.js:1255:31
attemptSync
run
execute
queueRunnerFactory
execute
fn
attemptAsync
run
execute
queueRunnerFactory
fn
attemptAsync
run
execute
queueRunnerFactory
execute
execute
runTests@file:///app/tns_modules/nativescript-unit-test-runner/main-view-model.js:216:23
file:///app/tns_modules/nativescript-unit-test-runner/main-view-model.js:187:101
tick@file:///app/tns_modules/timer/timer.js:17:26
UIApplicationMain@[native code]
start@file:///app/tns_modules/application/application.js:234:26
anonymous@file:///app/./tns_modules/nativescript-unit-test-runner/app.js:3:18
evaluate@[native code]
moduleEvaluation@[native code]
[native code]
promiseReactionJob@[native code]
NativeScript / 10.0 (10.0; iPhone) UserService just testing FAILED
TypeError: undefined is not an object (evaluating 'ProxyZoneSpec.assertPresent') in file:///app/tns_modules/@angular/core/testing/../bundles/core-testing.umd.js (line 385)
resetFakeAsyncZone@file:///app/tns_modules/@angular/core/testing/../bundles/core-testing.umd.js:385:22
file:///app/tns_modules/@angular/core/testing/../bundles/core-testing.umd.js:1255:31
attemptSync
run
execute
queueRunnerFactory
execute
fn
attemptAsync
run
execute
queueRunnerFactory
fn
attemptAsync
run
onComplete
clearStack
run
complete
clearStack
run
execute
queueRunnerFactory
execute
fn
attemptAsync
run
execute
queueRunnerFactory
fn
attemptAsync
run
execute
queueRunnerFactory
execute
execute
runTests@file:///app/tns_modules/nativescript-unit-test-runner/main-view-model.js:216:23
file:///app/tns_modules/nativescript-unit-test-runner/main-view-model.js:187:101
tick@file:///app/tns_modules/timer/timer.js:17:26
UIApplicationMain@[native code]
start@file:///app/tns_modules/application/application.js:234:26
anonymous@file:///app/./tns_modules/nativescript-unit-test-runner/app.js:3:18
evaluate@[native code]
moduleEvaluation@[native code]
[native code]
promiseReactionJob@[native code]
NativeScript / 10.0 (10.0; iPhone): Executed 2 of 2 (2 FAILED) ERROR (0.02 secs / 0.002 secs)

I have tried various things like import zone.js / dist / proxy.js and many other things without success.

- , ? , unit test script ???

+4
1

TestBed NativeScript Angular.

NativeScript. .

0

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


All Articles