-
-
Notifications
You must be signed in to change notification settings - Fork 241
Testbed + nativescript-angular 1.5.1 #733
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
Comments
Supporting TestBed tests has been on our todo list for some time, but we haven't gotten to actually spending any effort on it yet. I can say if it's worked before it was purely by accident. :-) That said, we will probably accept a PR that fixes the issue at hand. |
@hdeshev |
@Rachnerd's idea to replace setGlobalVar made it work for me. I can use TestBed. |
app/tests/config.ts import 'nativescript-angular/zone-js/dist/zone-nativescript';
import 'zone.js/dist/long-stack-trace-zone';
import 'zone.js/dist/async-test';
import 'zone.js/dist/fake-async-test';
import 'zone.js/dist/sync-test';
import 'zone.js/dist/proxy';
global.window = global;
import 'zone.js/dist/mocha-patch';
import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing';
import { NS_COMPILER_PROVIDERS } from 'nativescript-angular/platform';
import { TestBed } from '@angular/core/testing';
import * as chai from 'chai';
import * as sinonChai from 'sinon-chai';
/**
* 1.5.1 Workaround
*/
import { NativeScriptDomAdapter } from 'nativescript-angular/dom-adapter';
NativeScriptDomAdapter.prototype.setGlobalVar = (_name: any, _value: any): void => {
return;
};
chai.use(sinonChai);
chai.config.truncateThreshold = 0;
TestBed.initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting(NS_COMPILER_PROVIDERS)); karma.conf.js module.exports = function ( config ) {
config.set( {
...
frameworks: [ 'mocha', 'chai', 'sinon' ],
// list of files / patterns to load in the browser
files: [
'app/tests/config.js', // <- Config first
'app/tests/**/*.spec.js' // <- Spec files
],
...
} |
@kamok I know what you mean. We simply use TestBed as a dependency injector for service tests. If a component contains some logic that needs testing, then we manually instantiate the component using the injected dependencies. No template testing though... |
Hi friends,
Since I upgraded to Angular 4 + nativescript-angular 1.5.1 all unit tests involving Testbed broke.
I managed to reproduce this error quite easily in the sample-groceries app (release branch).
Files:
I managed to get it working again by overriding the function that throws the error.
Other info
I assume this is unwanted behavior? :)
The text was updated successfully, but these errors were encountered: