-
Notifications
You must be signed in to change notification settings - Fork 41
Description
I am using following env:
- Angular2+Angular CLI
- Using PhantomJS+Jasmin+Karma
following is my karma.conf.js file:
// Karma configuration file, see link for more information
// https://karma-runner.github.io/0.13/config/configuration-file.html
module.exports = function (config) {
config.set({
basePath: '..',
frameworks: ['jasmine'],
/plugins: [
require('karma-jasmine')
require('karma-chrome-launcher')
],
customLaunchers: {
// chrome setup for travis CI using chromium
Chrome_travis_ci: {
base: 'Chrome',
flags: ['--no-sandbox']
}
},/
files: [
{ pattern: 'dist/vendor/es6-shim/es6-shim.js', included: true, watched: false },
{ pattern: 'dist/vendor/zone.js/dist/zone.js', included: true, watched: false },
{ pattern: 'dist/vendor/reflect-metadata/Reflect.js', included: true, watched: false },
{ pattern: 'dist/vendor/systemjs/dist/system-polyfills.js', included: true, watched: false },
{ pattern: 'dist/vendor/systemjs/dist/system.src.js', included: true, watched: false },
{ pattern: 'dist/vendor/zone.js/dist/async-test.js', included: true, watched: false },
{ pattern: 'dist/vendor/zone.js/dist/fake-async-test.js', included: true, watched: false },
{ pattern: 'config/karma-test-shim.js', included: true, watched: true },
// Distribution folder.
{ pattern: 'dist/**/*', included: false, watched: true }
],
exclude: [
// Vendor packages might include spec files. We don't want to use those.
'dist/vendor/**/*.spec.js'
],
preprocessors: {
'/dist/app/**/*.js': ['coverage']
},
'coverageReporter': {
type: 'html',
dir: 'coverage/'
},
reporters: ['progress','coverage'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
//autoWatch: false,
//browsers: ['Chrome'],
browsers: ['PhantomJS'],
//singleRun: false
browserNoActivityTimeout: 100000,
singleRun: true
});
};
One of the test case:
import {
beforeEach, beforeEachProviders,
describe, xdescribe,
expect, it, xit,
async, inject
} from '@angular/core/testing';
import { AccountSummaryService } from './account-summary.service';
import { HTTP_PROVIDERS, RequestMethod, Response, ResponseOptions, XHRBackend, BaseRequestOptions} from '@angular/http'
import { MockBackend, MockConnection } from '@angular/http/testing';
describe('AccountSummary Service', () => {
let mockBackend: MockBackend;
beforeEachProviders(() => [
HTTP_PROVIDERS,
{ provide: XHRBackend, useClass: MockBackend },
AccountSummaryService
]);
beforeEach(inject([MockBackend], (backend: MockBackend) => {
mockBackend = backend;
}));
it('should ...',
inject([AccountSummaryService], (service: AccountSummaryService) => {
mockBackend.connections.subscribe((connection: MockConnection) => {
expect(connection.request.method).toBe(RequestMethod.Get);
expect(connection.request.url).toBe('recovery/accounts/fdfd');
expect(connection.request.getBody()).toEqual(JSON.stringify({}));
return connection.mockRespond(new Response(new ResponseOptions({ body: 'body', status: 200 })));
});
expect(service.getAccountSummary("fdfd")).toBeTruthy();
}));
});
Execution:
^Cf45c89bd8b9b:recoveries-app nai628$ ng test --no-watch
Could not start watchman; falling back to NodeWatcher for file system events.
Visit http://ember-cli.com/user-guide/#watchman for more info.
Built project successfully. Stored in "dist/".
DEPRECATED: use your own version of lodash, this will go away in karma@2.0
DEPRECATED: use your own version of lodash, this will go away in karma@2.0
12 07 2016 11:31:36.994:INFO [karma]: Karma v1.1.1 server started at http://localhost:9876/
12 07 2016 11:31:36.996:INFO [launcher]: Launching browser PhantomJS with unlimited concurrency
12 07 2016 11:31:37.001:INFO [launcher]: Starting browser PhantomJS
12 07 2016 11:31:37.519:INFO [PhantomJS 2.1.1 (Mac OS X 0.0.0)]: Connected on socket /#IC5HGr-Q6SqNZ-fNAAAA with id 38920043
12 07 2016 11:31:38.335:WARN [web-server]: 404: /base/dist/traceur
PhantomJS 2.1.1 (Mac OS X 0.0.0) ERROR
{
"stack": null,
"originalErr": {},
"line": 821,
"sourceURL": "dist/vendor/systemjs/dist/system.src.js"
}
I am getting
12 07 2016 11:31:38.335:WARN [web-server]: 404: /base/dist/traceur
PhantomJS 2.1.1 (Mac OS X 0.0.0) ERROR
{
"stack": null,
"originalErr": {},
"line": 821,
"sourceURL": "dist/vendor/systemjs/dist/system.src.js"
}
I really wondering where i am getting the issue. Can any one help me out. this is very serious issue for me. Appreciate in advance.