I'm getting the below error while ruing my tests using Karma with Jasmine in my Angular2 with NativeScript project. The tests are being executed correctly, but, this error keeps repeating in the console. I observed the error is coming only after importing zone.js (imported it because it says zone is not defined while using inject, etc from Angular2/testing).
Error:
JS: NSUTR-socket.io: transport error JS: NSUTR-socket.io: 1 JS: NSUTR: socket.io error on coect: Error: xhr poll error JS: NSUTR-socket.io: 2 JS: NSUTR: socket.io error on coect: Error: xhr poll error 04 05 2016 12:33:42.046:WARN [NativeScript / 23 (6.0; Google Nexus 6P - 6.0.0 - API 23 - 1440x2560)]: D iscoected (1 times), because no message in 10000 ms. JS: NSUTR-socket.io: 3 JS: NSUTR: socket.io error on coect: Error: xhr poll error JS: NSUTR-socket.io: 4 JS: NSUTR: socket.io error on coect: Error: xhr poll error
My spec (test) file:
import 'reflect-metadata';
import 'zone.js/dist/zone.min.js';
import {Home} from '../components/home/home';
import {inject, beforeEachProviders, it, describe, expect} from 'angular2/testing';
beforeEachProviders(() => [Home]);
describe('Home Page ActionBar Title Test', () => {
// it('Title has text', () => {
it('Title has text', inject([Home], (homeObj: Home) => {
expect(homeObj.title).toBe('CapacityReview');
// expect(true).toBe(true);
}));
});
Package.json:
"dependencies": { "angular2": "2.0.0-beta.16", "es6-shim": "0.35.0", "nativescript-angular": "0.0.46", "nativescript-intl": "0.0.2", "nativescript-unit-test-ruer": "^0.3.3", "parse5": "1.4.2", "punycode": "1.3.2", "querystring": "0.2.0", "reflect-metadata": "0.1.2", "rxjs": "5.0.0-beta.2", "tns-core-modules": "2.0.0", "url": "0.10.3", "zone.js": "0.6.12" }, "devDependencies": { "babel-traverse": "6.7.6", "babel-types": "6.7.7", "babylon": "6.7.0", "filewalker": "0.1.2", "jasmine-core": "^2.4.1", "karma": "^0.13.22", "karma-jasmine": "^0.3.8", "karma-nativescript-launcher": "^0.4.0", "lazy": "1.0.11", "nativescript-dev-typescript": "^0.3.1", "typescript": "^1.8.10" }
karma.conf.js (default one): >
module.exports = function(config) { config.set({ // base path that will be used to resolve all pattes (eg. files, exclude) basePath: '', // frameworks to use // available frameworks: https://npmjs.org/browse/keyword/karma-adapter frameworks: ['jasmine'], // list of files / pattes to load in the browser files: [ 'app/**/*.js' ], // list of files to exclude exclude: [ ], // preprocess matching files before serving them to the browser // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor preprocessors: { }, // test results reporter to use // possible values: 'dots', 'progress' // available reporters: https://npmjs.org/browse/keyword/karma-reporter reporters: ['progress'], // web server port port: 9876, // enable / disable colors in the output (reporters and logs) colors: true, // level of logging // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG logLevel: config.LOG_INFO, // enable / disable watching file and executing tests whenever any file changes autoWatch: true, // start these browsers // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher browsers: [], customLaunchers: { android: { base: 'NS', platform: 'android' }, ios: { base: 'NS', platform: 'ios' }, ios_simulator: { base: 'NS', platform: 'ios', arguments: ['--emulator'] } }, // Continuous Integration mode // if true, Karma captures browsers, runs the tests and exits singleRun: false }) }
