Skip to content

Unit Testing with ns7 #9346

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
mansiTT opened this issue Apr 20, 2021 · 7 comments
Open

Unit Testing with ns7 #9346

mansiTT opened this issue Apr 20, 2021 · 7 comments

Comments

@mansiTT
Copy link

mansiTT commented Apr 20, 2021

tns : 7.0.6

Describe the bug
We are facing issue in integrating unit testing in our codebase. We have followed steps mentioned in the documentation for integrating the unit test framework.
Ref Doc : https://docs.nativescript.org/development-workflow.html#angular-testbed-integration
Imports mentioned in the docs are not compatible with ns7. It keeps giving error.

We have tried updating the imports

from :
import 'nativescript-angular/zone-js/testing.jasmine'
import { nsTestBedInit } from 'nativescript-angular/testing'
nsTestBedInit()

to :

import '@nativescript/zone-js/testing.jasmine'
import { nsTestBedInit } from '@nativescript/angular/testing'
nsTestBedInit()

Its giving error :

CONSOLE LOG: NSUTR: this.error: ReferenceError: Zone is not defined
at /base/src/tests/setup.bundle.js?23f4da92075f9f283030879ef2e337b8e3487aa3
20 04 2021 14:04:28.882:WARN [NativeScript / 14.1 (14.1; iPhone)]: Adapter did not report total number of specs.
NativeScript / 14.1 (14.1; iPhone): Executed 0 of null SUCCESS (0 secs / 0 secs)
NativeScript / 14.1 (14.1; iPhone) /base/src/tests/setup.bundle.js?23f4da92075f9f283030879ef2e337b8e3487aa3 at line 0 FAILED
ReferenceError: Zone is not defined
NativeScript / 14.1 (14.1; iPhone): Executed 1 of null (1 FAILED) (0.003 secs / 0 secs)
TOTAL: 1 FAILED, 0 SUCCESS

@NathanWalker
Copy link
Contributor

@mansiTT We're working on a blog post to cover this - targeting for publishing this week or the following. There will be a revised unit testing section in docs on this as well.

@mansiTT
Copy link
Author

mansiTT commented Apr 24, 2021

That would be a great help. Thanks

@cwolff-wells
Copy link

try doing
import '@nativescript/zone-js';
import 'zone.js/dist/zone-testing';

// you will need this unless you have NativeScript/nativescript-angular#2340
if (typeof Node === 'undefined' && !global.Node) {
class DummyNode {}
global.Node = DummyNode as any;
}

nsTestBedInit();

@dimiii
Copy link

dimiii commented May 11, 2021

targeting for publishing this week or the following. There will be a revised unit testing section in docs on this as well.

What is the progress?

@NathanWalker
Copy link
Contributor

https://blog.nativescript.org/unit-testing/index.html

A subsequent flavor specific post will be put up as well.

@Neos02
Copy link

Neos02 commented May 25, 2021

I created a new project using ng new --collection=@nativescript/schematics project-name --shared and after following the testing documentation I am getting the same warning.

@tasar1990
Copy link

https://blog.nativescript.org/unit-testing/index.html

A subsequent flavor specific post will be put up as well.

@NathanWalker if you can include also how to configure TestBed that will be great ... I am also facing errors like

"Executed 1 of null (1 FAILED) (0.046 secs / 0 secs)" OR "Executed 0 of 0 Succes (0.046 secs / 0 secs)"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants