nativescript-angular: Not able to configure a module from TestBed.configureTestingModule
From @ignaciolarranaga on September 28, 2016 21:3
Please, provide the details below:
Tell us about the problem
I can not configure a testing module, on the start of the tests it throws:
NativeScript / 9.1 (9.1; iPhone) ../../tests/shared/services/user.service.spec.js at line 0 FAILED
ReferenceError: Can't find variable: Zone
NativeScript / 9.1 (9.1; iPhone): Executed 1 of 0 (1 FAILED) ERROR (0.033 secs / 0 secs)
Which platform(s) does your issue occur on?
iOS
Please provide the following version numbers that your issue occurs with:
- CLI: 2.3.0
- Cross-platform modules: tns-core-modules: 2.3.0
- Runtime(s): ios 2.3.0
Please tell us how to recreate the issue in as much detail as possible.
Just try to configure a test module
Is there code involved? If so, please share the minimal amount of code needed to recreate the problem.
import { TestBed } from "@angular/core/testing";
import { NativeScriptModule } from "nativescript-angular/platform";
import { NativeScriptFormsModule } from "nativescript-angular/forms"
import { NativeScriptHttpModule } from "nativescript-angular/http";
import { UserService } from "../../../shared/services";
import { IdentifiedHttp } from "../../../shared/util";
describe("UserService tests", () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [
NativeScriptModule,
NativeScriptFormsModule,
NativeScriptHttpModule,
],
declarations: [ UserService ],
providers: [ IdentifiedHttp ]
});
});
});
Copied from original issue: NativeScript/NativeScript#2814
About this issue
- Original URL
- State: open
- Created 8 years ago
- Comments: 15 (5 by maintainers)
Is TestBed supported in NativeScript? It seems like there are a bunch of potential workarounds that everyone tries, but without success. It is very important for my team to be able to use TestBed to initialize components which have numerous dependencies.
Hey,
I have been working on trying to get TestBed configured properly in NativeScript for a month now and still haven’t gotten it. The example provided is not sufficient as I have attempted to reproduce it and still face issues. I am unsure of what I am doing wrong.
Please checkout my Stack Overflow question if you have been able to get TestBed working in NativeScript I would very much appreciate it.
https://stackoverflow.com/questions/57186925/how-to-implement-unit-tests-in-nativescript-using-testbed-and-jasmine
you can take a look at my angular sample here: https://github.com/TobiasHennig/nativescript-toast/blob/master/samples/angular/app/tests/app.component.spec.ts
I’ve using TestBed: https://github.com/TobiasHennig/nativescript-toast/blob/master/samples/angular/app/tests/setup.js
you can check it for yourself, just clone the repo:
I get