I'm having an issue getting any tests to run now that I have Karma starting without any issues. I can see in the mand line acknowledging my spec files, however, no tests are being run, seeing "Chrome 53.0.2785 (Windows 7 0.0.0): Executed 0 of 0 ERROR (0.005 secs / 0 secs)":
> [email protected] test C:\src\testingexample
> tsc && concurrently "tsc -w" "karma start karma.conf.js"
[1] [WARNING] Looking up paths with require.resolve() is deprecated.
[1] Please add "systemjs" to your SystemJS config paths.
[1] [WARNING] Looking up paths with require.resolve() is deprecated.
[1] Please add "traceur" to your SystemJS config paths.
[1] 27 09 2016 16:06:07.265:WARN [karma]: No captured browser, open http://localhost:9876/
[1] 27 09 2016 16:06:07.307:WARN [karma]: Port 9876 in use
[1] 27 09 2016 16:06:07.309:INFO [karma]: Karma v1.3.0 server started at http://localhost:9877/
[1] 27 09 2016 16:06:07.309:INFO [launcher]: Launching browser Chrome with unlimited concurrency
[1] 27 09 2016 16:06:07.364:INFO [launcher]: Starting browser Chrome
[1] 27 09 2016 16:06:08.151:INFO [Chrome 53.0.2785 (Windows 7 0.0.0)]: Connected on socket /#r4UrKTjwWvF4GtokAAAA with i
d 75686393
Chrome 53.0.2785 (Windows 7 0.0.0): Executed 0 of 0 ERROR (0.004 secs / 0 secs)
[1] 27 09 2016 16:06:10.172:INFO [watcher]: Changed file "C:/src/testingexample/test/1st.spec.js".
[1] 27 09 2016 16:06:10.194:INFO [watcher]: Changed file "C:/src/testingexample/test/ponents/header/header.spec.js".
[0] 4:06:10 PM - Compilation plete. Watching for file changes.
Chrome 53.0.2785 (Windows 7 0.0.0): Executed 0 of 0 ERROR (0.005 secs / 0 secs)
Project structure:
app/
├── mon/
├── ponents/
| └── header/
| ├── headerponent.css
| ├── headerponent.html
| └── headerponent.ts
test/
├── ponents/
| └── header/
| └── header.spec.ts
├── models/
└── services/
karma-test-shim.js
karma.conf.js
systemjs.config.js
packages.json (likely polluted from trying to get everything to start without errors):
{
"name": "testingexample",
"version": "0.0.1",
"scripts": {
"start": "tsc && concurrently \"npm run tsc:w\" \"npm run lite\" ",
"test": "tsc && concurrently \"tsc -w\" \"karma start karma.conf.js\"",
"test-once": "tsc && karma start karma.conf.js --single-run",
"lite": "lite-server",
"lint": "tslint ./app/**/*.ts -t verbose",
"postinstall": "typings install",
"tsc": "tsc",
"tsc:w": "tsc -w",
"typings": "typings"
},
"license": "ISC",
"dependencies": {
"@angular/mon": "2.0.0",
"@angular/piler": "2.0.0",
"@angular/core": "2.0.0",
"@angular/forms": "2.0.0",
"@angular/http": "2.0.0",
"@angular/platform-browser": "2.0.0",
"@angular/platform-browser-dynamic": "2.0.0",
"@angular/router": "3.0.0",
"@angular/upgrade": "2.0.0",
"systemjs": "0.19.27",
"core-js": "^2.4.1",
"reflect-metadata": "^0.1.3",
"rxjs": "5.0.0-beta.12",
"zone.js": "^0.6.23",
"angular2-in-memory-web-api": "0.0.20",
"bootstrap": "^3.3.6"
},
"devDependencies": {
"brfs": "^1.4.3",
"browserify": "^13.1.0",
"concurrently": "^2.2.0",
"http-server": "^0.9.0",
"jasmine": "^2.5.2",
"jasmine-core": "^2.4.1",
"karma": "^1.2.0",
"karma-browserify": "^5.1.0",
"karma-chrome-launcher": "^0.2.3",
"karma-cli": "^0.1.2",
"karma-htmlfile-reporter": "^0.2.2",
"karma-jasmine": "^0.3.8",
"karma-systemjs": "^0.15.0",
"lite-server": "^2.2.0",
"phantomjs": "^2.1.7",
"protractor": "^3.3.0",
"traceur": "0.0.111",
"tslint": "^3.7.4",
"typescript": "^2.0.2",
"typings": "^1.0.4",
"watchify": "^3.7.0"
}
}
karma-test-shim.js (this seems pretty standard):
// #docregion
// /*global jasmine, __karma__, window*/
Error.stackTraceLimit = 0;
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000;
var builtPath = '/base/app/';
__karma__.loaded = function () { };
function isJsFile(path) {
return path.slice(-3) == '.js';
}
function isSpecFile(path) {
return /\.spec\.(.*\.)?js$/.test(path);
}
function isBuiltFile(path) {
return isJsFile(path) && (path.substr(0, builtPath.length) == builtPath);
}
var allSpecFiles = Object.keys(window.__karma__.files)
.filter(isSpecFile)
.filter(isBuiltFile);
System.config({
baseURL: '/base',
// Extend usual application package list with test folder
packages: { 'testing': { main: 'index.js', defaultExtension: 'js' } },
// Assume npm: is set in `paths` in systemjs.config
// Map the angular testing umd bundles
map: {
'@angular/core/testing': 'npm:@angular/core/bundles/core-testing.umd.js',
'@angular/mon/testing': 'npm:@angular/mon/bundles/mon-testing.umd.js',
'@angular/piler/testing': 'npm:@angular/piler/bundles/piler-testing.umd.js',
'@angular/platform-browser/testing': 'npm:@angular/platform-browser/bundles/platform-browser-testing.umd.js',
'@angular/platform-browser-dynamic/testing': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic-testing.umd.js',
'@angular/http/testing': 'npm:@angular/http/bundles/http-testing.umd.js',
'@angular/router/testing': 'npm:@angular/router/bundles/router-testing.umd.js',
'@angular/forms/testing': 'npm:@angular/forms/bundles/forms-testing.umd.js',
},
});
System.import('systemjs.config.js')
.then(importSystemJsExtras)
.then(initTestBed)
.then(initTesting);
/** Optional SystemJS configuration extras. Keep going w/o it */
function importSystemJsExtras(){
return System.import('systemjs.config.extras.js')
.catch(function(reason) {
console.log(
'WARNING: System.import could not load "systemjs.config.extras.js"; continuing without it.'
);
console.log(reason);
});
}
function initTestBed(){
return Promise.all([
System.import('@angular/core/testing'),
System.import('@angular/platform-browser-dynamic/testing')
])
.then(function (providers) {
var coreTesting = providers[0];
var browserTesting = providers[1];
coreTesting.TestBed.initTestEnvironment(
browserTesting.BrowserDynamicTestingModule,
browserTesting.platformBrowserDynamicTesting());
})
}
// Import all spec files and start karma
function initTesting () {
return Promise.all(
allSpecFiles.map(function (moduleName) {
return System.import(moduleName);
})
)
.then(__karma__.start, __karma__.error);
}
karma.conf.js:
// #docregion
module.exports = function(config) {
var appBase = 'app/'; // transpiled app JS and map files
var appSrcBase = 'app/'; // app source TS files
var appAssets = 'app/'; // ponent assets fetched by Angular's piler
var testBase = 'test/'; // transpiled test JS and map files
var testSrcBase = 'test/'; // test source TS files
config.set({
basePath: '',
frameworks: ['systemjs','jasmine'],
plugins: [
require('karma-systemjs'),
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-htmlfile-reporter'),
require('karma-browserify'),
require('browserify')
],
customLaunchers: {
// From the CLI. Not used here but interesting
// chrome setup for travis CI using chromium
Chrome_travis_ci: {
base: 'Chrome',
flags: ['--no-sandbox']
}
},
files: [
// System.js for module loading
'node_modules/systemjs/dist/system-polyfills.js',
'node_modules/systemjs/dist/system.src.js',
// Reflect and Zone.js
'node_modules/reflect-metadata/Reflect.js',
'node_modules/zone.js/dist/zone.js',
'node_modules/zone.js/dist/long-stack-trace-zone.js',
'node_modules/zone.js/dist/async-test.js',
'node_modules/zone.js/dist/fake-async-test.js',
'node_modules/zone.js/dist/sync-test.js',
'node_modules/zone.js/dist/proxy.js',
'node_modules/zone.js/dist/jasmine-patch.js',
// RxJs.
{ pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false },
{ pattern: 'node_modules/rxjs/**/*.js.map', included: false, watched: false },
// Angular 2 itself and the testing library
{pattern: 'node_modules/@angular/**/*.js', included: false, watched: false},
{pattern: 'node_modules/@angular/**/*.js.map', included: false, watched: false},
'karma-test-shim.js',
'test/**/*spec.js'
],
// Proxied base paths for loading assets
proxies: {
// required for ponent assets fetched by Angular's piler
"/app/": appAssets
},
exclude: [],
preprocessors: {
},
reporters: ['progress', 'html'],
// HtmlReporter configuration
htmlReporter: {
// Open this file to see results in browser
outputFile: '_test-output/tests.html',
// Optional
pageTitle: 'Unit Tests',
subPageTitle: __dirname
},
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false
})
}
and finally, systemjs.config.js:
(function (global) {
System.config({
paths: {
// paths serve as alias
'npm:': 'node_modules/'
},
// map tells the System loader where to look for things
map: {
// our app is within the app folder
app: 'app',
// angular bundles
'@angular/core': 'npm:@angular/core/bundles/core.umd.js',
'@angular/mon': 'npm:@angular/mon/bundles/mon.umd.js',
'@angular/piler': 'npm:@angular/piler/bundles/piler.umd.js',
'@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
'@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
'@angular/http': 'npm:@angular/http/bundles/http.umd.js',
'@angular/router': 'npm:@angular/router/bundles/router.umd.js',
'@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
// other libraries
'rxjs': 'npm:rxjs',
'angular2-in-memory-web-api': 'npm:angular2-in-memory-web-api',
},
// packages tells the System loader how to load when no filename and/or no extension
packages: {
app: {
main: './main.js',
defaultExtension: 'js'
},
rxjs: {
defaultExtension: 'js'
},
'angular2-in-memory-web-api': {
main: './index.js',
defaultExtension: 'js'
}
}
});
})(this);
I know that is a ton to go through - I hope i'm doing something obviously wrong.
I'm having an issue getting any tests to run now that I have Karma starting without any issues. I can see in the mand line acknowledging my spec files, however, no tests are being run, seeing "Chrome 53.0.2785 (Windows 7 0.0.0): Executed 0 of 0 ERROR (0.005 secs / 0 secs)":
> [email protected] test C:\src\testingexample
> tsc && concurrently "tsc -w" "karma start karma.conf.js"
[1] [WARNING] Looking up paths with require.resolve() is deprecated.
[1] Please add "systemjs" to your SystemJS config paths.
[1] [WARNING] Looking up paths with require.resolve() is deprecated.
[1] Please add "traceur" to your SystemJS config paths.
[1] 27 09 2016 16:06:07.265:WARN [karma]: No captured browser, open http://localhost:9876/
[1] 27 09 2016 16:06:07.307:WARN [karma]: Port 9876 in use
[1] 27 09 2016 16:06:07.309:INFO [karma]: Karma v1.3.0 server started at http://localhost:9877/
[1] 27 09 2016 16:06:07.309:INFO [launcher]: Launching browser Chrome with unlimited concurrency
[1] 27 09 2016 16:06:07.364:INFO [launcher]: Starting browser Chrome
[1] 27 09 2016 16:06:08.151:INFO [Chrome 53.0.2785 (Windows 7 0.0.0)]: Connected on socket /#r4UrKTjwWvF4GtokAAAA with i
d 75686393
Chrome 53.0.2785 (Windows 7 0.0.0): Executed 0 of 0 ERROR (0.004 secs / 0 secs)
[1] 27 09 2016 16:06:10.172:INFO [watcher]: Changed file "C:/src/testingexample/test/1st.spec.js".
[1] 27 09 2016 16:06:10.194:INFO [watcher]: Changed file "C:/src/testingexample/test/ponents/header/header.spec.js".
[0] 4:06:10 PM - Compilation plete. Watching for file changes.
Chrome 53.0.2785 (Windows 7 0.0.0): Executed 0 of 0 ERROR (0.005 secs / 0 secs)
Project structure:
app/
├── mon/
├── ponents/
| └── header/
| ├── header.ponent.css
| ├── header.ponent.html
| └── header.ponent.ts
test/
├── ponents/
| └── header/
| └── header.spec.ts
├── models/
└── services/
karma-test-shim.js
karma.conf.js
systemjs.config.js
packages.json (likely polluted from trying to get everything to start without errors):
{
"name": "testingexample",
"version": "0.0.1",
"scripts": {
"start": "tsc && concurrently \"npm run tsc:w\" \"npm run lite\" ",
"test": "tsc && concurrently \"tsc -w\" \"karma start karma.conf.js\"",
"test-once": "tsc && karma start karma.conf.js --single-run",
"lite": "lite-server",
"lint": "tslint ./app/**/*.ts -t verbose",
"postinstall": "typings install",
"tsc": "tsc",
"tsc:w": "tsc -w",
"typings": "typings"
},
"license": "ISC",
"dependencies": {
"@angular/mon": "2.0.0",
"@angular/piler": "2.0.0",
"@angular/core": "2.0.0",
"@angular/forms": "2.0.0",
"@angular/http": "2.0.0",
"@angular/platform-browser": "2.0.0",
"@angular/platform-browser-dynamic": "2.0.0",
"@angular/router": "3.0.0",
"@angular/upgrade": "2.0.0",
"systemjs": "0.19.27",
"core-js": "^2.4.1",
"reflect-metadata": "^0.1.3",
"rxjs": "5.0.0-beta.12",
"zone.js": "^0.6.23",
"angular2-in-memory-web-api": "0.0.20",
"bootstrap": "^3.3.6"
},
"devDependencies": {
"brfs": "^1.4.3",
"browserify": "^13.1.0",
"concurrently": "^2.2.0",
"http-server": "^0.9.0",
"jasmine": "^2.5.2",
"jasmine-core": "^2.4.1",
"karma": "^1.2.0",
"karma-browserify": "^5.1.0",
"karma-chrome-launcher": "^0.2.3",
"karma-cli": "^0.1.2",
"karma-htmlfile-reporter": "^0.2.2",
"karma-jasmine": "^0.3.8",
"karma-systemjs": "^0.15.0",
"lite-server": "^2.2.0",
"phantomjs": "^2.1.7",
"protractor": "^3.3.0",
"traceur": "0.0.111",
"tslint": "^3.7.4",
"typescript": "^2.0.2",
"typings": "^1.0.4",
"watchify": "^3.7.0"
}
}
karma-test-shim.js (this seems pretty standard):
// #docregion
// /*global jasmine, __karma__, window*/
Error.stackTraceLimit = 0;
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000;
var builtPath = '/base/app/';
__karma__.loaded = function () { };
function isJsFile(path) {
return path.slice(-3) == '.js';
}
function isSpecFile(path) {
return /\.spec\.(.*\.)?js$/.test(path);
}
function isBuiltFile(path) {
return isJsFile(path) && (path.substr(0, builtPath.length) == builtPath);
}
var allSpecFiles = Object.keys(window.__karma__.files)
.filter(isSpecFile)
.filter(isBuiltFile);
System.config({
baseURL: '/base',
// Extend usual application package list with test folder
packages: { 'testing': { main: 'index.js', defaultExtension: 'js' } },
// Assume npm: is set in `paths` in systemjs.config
// Map the angular testing umd bundles
map: {
'@angular/core/testing': 'npm:@angular/core/bundles/core-testing.umd.js',
'@angular/mon/testing': 'npm:@angular/mon/bundles/mon-testing.umd.js',
'@angular/piler/testing': 'npm:@angular/piler/bundles/piler-testing.umd.js',
'@angular/platform-browser/testing': 'npm:@angular/platform-browser/bundles/platform-browser-testing.umd.js',
'@angular/platform-browser-dynamic/testing': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic-testing.umd.js',
'@angular/http/testing': 'npm:@angular/http/bundles/http-testing.umd.js',
'@angular/router/testing': 'npm:@angular/router/bundles/router-testing.umd.js',
'@angular/forms/testing': 'npm:@angular/forms/bundles/forms-testing.umd.js',
},
});
System.import('systemjs.config.js')
.then(importSystemJsExtras)
.then(initTestBed)
.then(initTesting);
/** Optional SystemJS configuration extras. Keep going w/o it */
function importSystemJsExtras(){
return System.import('systemjs.config.extras.js')
.catch(function(reason) {
console.log(
'WARNING: System.import could not load "systemjs.config.extras.js"; continuing without it.'
);
console.log(reason);
});
}
function initTestBed(){
return Promise.all([
System.import('@angular/core/testing'),
System.import('@angular/platform-browser-dynamic/testing')
])
.then(function (providers) {
var coreTesting = providers[0];
var browserTesting = providers[1];
coreTesting.TestBed.initTestEnvironment(
browserTesting.BrowserDynamicTestingModule,
browserTesting.platformBrowserDynamicTesting());
})
}
// Import all spec files and start karma
function initTesting () {
return Promise.all(
allSpecFiles.map(function (moduleName) {
return System.import(moduleName);
})
)
.then(__karma__.start, __karma__.error);
}
karma.conf.js:
// #docregion
module.exports = function(config) {
var appBase = 'app/'; // transpiled app JS and map files
var appSrcBase = 'app/'; // app source TS files
var appAssets = 'app/'; // ponent assets fetched by Angular's piler
var testBase = 'test/'; // transpiled test JS and map files
var testSrcBase = 'test/'; // test source TS files
config.set({
basePath: '',
frameworks: ['systemjs','jasmine'],
plugins: [
require('karma-systemjs'),
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-htmlfile-reporter'),
require('karma-browserify'),
require('browserify')
],
customLaunchers: {
// From the CLI. Not used here but interesting
// chrome setup for travis CI using chromium
Chrome_travis_ci: {
base: 'Chrome',
flags: ['--no-sandbox']
}
},
files: [
// System.js for module loading
'node_modules/systemjs/dist/system-polyfills.js',
'node_modules/systemjs/dist/system.src.js',
// Reflect and Zone.js
'node_modules/reflect-metadata/Reflect.js',
'node_modules/zone.js/dist/zone.js',
'node_modules/zone.js/dist/long-stack-trace-zone.js',
'node_modules/zone.js/dist/async-test.js',
'node_modules/zone.js/dist/fake-async-test.js',
'node_modules/zone.js/dist/sync-test.js',
'node_modules/zone.js/dist/proxy.js',
'node_modules/zone.js/dist/jasmine-patch.js',
// RxJs.
{ pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false },
{ pattern: 'node_modules/rxjs/**/*.js.map', included: false, watched: false },
// Angular 2 itself and the testing library
{pattern: 'node_modules/@angular/**/*.js', included: false, watched: false},
{pattern: 'node_modules/@angular/**/*.js.map', included: false, watched: false},
'karma-test-shim.js',
'test/**/*spec.js'
],
// Proxied base paths for loading assets
proxies: {
// required for ponent assets fetched by Angular's piler
"/app/": appAssets
},
exclude: [],
preprocessors: {
},
reporters: ['progress', 'html'],
// HtmlReporter configuration
htmlReporter: {
// Open this file to see results in browser
outputFile: '_test-output/tests.html',
// Optional
pageTitle: 'Unit Tests',
subPageTitle: __dirname
},
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false
})
}
and finally, systemjs.config.js:
(function (global) {
System.config({
paths: {
// paths serve as alias
'npm:': 'node_modules/'
},
// map tells the System loader where to look for things
map: {
// our app is within the app folder
app: 'app',
// angular bundles
'@angular/core': 'npm:@angular/core/bundles/core.umd.js',
'@angular/mon': 'npm:@angular/mon/bundles/mon.umd.js',
'@angular/piler': 'npm:@angular/piler/bundles/piler.umd.js',
'@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
'@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
'@angular/http': 'npm:@angular/http/bundles/http.umd.js',
'@angular/router': 'npm:@angular/router/bundles/router.umd.js',
'@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
// other libraries
'rxjs': 'npm:rxjs',
'angular2-in-memory-web-api': 'npm:angular2-in-memory-web-api',
},
// packages tells the System loader how to load when no filename and/or no extension
packages: {
app: {
main: './main.js',
defaultExtension: 'js'
},
rxjs: {
defaultExtension: 'js'
},
'angular2-in-memory-web-api': {
main: './index.js',
defaultExtension: 'js'
}
}
});
})(this);
I know that is a ton to go through - I hope i'm doing something obviously wrong.
Share Improve this question edited Sep 27, 2016 at 21:29 DankestMemes 1533 silver badges10 bronze badges asked Sep 27, 2016 at 19:12 MattMatt 6393 gold badges8 silver badges23 bronze badges 2- Karma is the test runner and jasmine is the testing framework in which the unit tests are written. I'll try to provide an answer when I get home if nothing else has helped you. – DankestMemes Commented Sep 27, 2016 at 21:01
- In my case there was nothing wrong with Karma/Jasmine settings. My spec file had an error. When I fixed that error test run as expected. Hope it helps someone else. – Ula Commented Apr 20, 2019 at 16:07
2 Answers
Reset to default 2I think this is because karma doesn't look at your spec files like testing file.
When it tells you that it has detected changes :
[1] 27 09 2016 16:06:10.194:INFO [watcher]: Changed file "C:/src/testingexample/test/ponents/header/header.spec.js".
It does not mean that it was a test file.
To tell karma which files are test files, you can see in karma-test-shim.js
var allSpecFiles = Object.keys(window.__karma__.files)
.filter(isSpecFile)
.filter(isBuiltFile);
It tells karma to load all files and then keep only those that are
isSpecFile
: something that ends with.spec.js
isBuiltFile
: something that is under the build path/base/app/
In your case, your test are not in the app
directory, so you have to remove the .filter(isBuiltFile)
so karma can handle you spec.js as tests.
I looked at my own karma tested project and I found some differencies.
In my karma.conf.js
I do not have any SystemJS plugin.
frameworks: ['jasmine'], plugins : [ require('karma-jasmine'), require('karma-chrome-launcher') ],
I have piled app and test JS added to
files
in place of your'test/**/*spec.js'
.{pattern: appBase + '**/*.js', included: false, watched: true}, {pattern: testBase + '**/*.js', included: false, watched: true},
I don't know if karma allows pattern without using
{pattern: 'test/**/*spec.js', ...}
.
In my karma-test-shim.js
- I do not use a systemjs.config.extras.js so I have removed all related code.
Would like to contribute with my solution, hope someone find it useful in the future.
First, I started my project using this setup.
I wanted to place my tests in spec/ folder following this structure:
src
└── app/
├── ponents/
| └── app.ponent.ts
├── models/
└── services/
main.ts
spec/
└── ponents/
└── app.ponent.spec.ts
karma-test-shim.js
karma.conf.js
systemjs.config.js
To make that work I did three changes:
1.- Change default testing folders in karma.config.js:
...
// Testing helpers (optional) are conventionally in a folder called `testing`
var testingBase = 'spec/'; // transpiled test JS and map files
var testingSrcBase = 'spec/'; // test source TS files
...
2.- Build spec/ folder while running npm test
, this is changing package.json file:
{
"name": "my app",
"version": "1.0.0",
...
"scripts": {
...
"build:test": "tsc -p spec/",
...
"test": "concurrently \"npm run build:test\" \"npm run build:watch\" \"karma start karma.conf.js\"",
...
}
...
}
3.- Create tsconfig.json file within spec/ folder, the information is:
{
"pilerOptions": {
"target": "es5",
"module": "monjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [ "es2015", "dom" ],
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true
}
}
While running npm test
, tsc will build all the .ts files generating .js and .js.map. Later, karma will run tests inside spec/ folder.
Seems tests are running twice, but not sure if something related to this configuration or how angular2 works.
Hope this help someone else.
Cheers. :)
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744181732a4562013.html
评论列表(0条)