How to implement unit tests in NativeScript using TestBed and Jasmine?
To use TestBed you have to alter your karma.conf.js
to:
// list of files / patterns to load in the browser
files: [
'src/tests/setup.ts',
'src/tests/**/*.spec.ts'
],
The file src/tests/setup.ts
should look like this for jasmine:
import "nativescript-angular/zone-js/testing.jasmine";
import {nsTestBedInit} from "nativescript-angular/testing";
nsTestBedInit();
or if using mocha:
import "nativescript-angular/zone-js/testing.mocha";
import {nsTestBedInit} from "nativescript-angular/testing";
nsTestBedInit();
You'll find a sample here: https://github.com/hypery2k/tns_testbed_sample