Reputation: 16266
I have the following karma.config.js
that is based on this
module.exports = function (config) {
config.set({
basePath: '',
files: ['**/*spec.ts'],
frameworks: ['jasmine'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter')
],
client: {
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
dir: require('path').join(__dirname, '../coverage'),
reports: ['html', 'lcovonly'],
fixWebpackSourcePaths: true
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false
});
};
I can not understand why that the report says that there was execute 0 tests. I'm sure that I have some files in my src folder that has the spec.ts
extension.
Chrome 68.0.3440 (Windows 10.0.0): Executed 0 of 0 ERROR (0.079 secs / 0 secs)
Any one has any idea what may be the issue?
Upvotes: 5
Views: 11305
Reputation: 119
That happens with my unit-tests , actually one of the unit tests I had
import { NO_ERRORS_SCHEMA } from '@angular/compiler/src/core';
which I replaced with
import { NO_ERRORS_SCHEMA } from '@angular/core';
Upvotes: 0
Reputation: 16266
In the context of this answer I realise that I didn't the follwoing files in my project:
I haven't realize early because this is a project that is install on another project. This means that I never had the need of running this project as a stand alone application.
To solve this issue, what I did was:
ng new my-app
Upvotes: 3
Reputation: 9774
You need to check the path in src/test.ts. Here is my code.
// Then we find all the tests.
const context = require.context('./', true, /\.spec\.ts$/);
// And load the modules.
context.keys().map(context);
// Finally, start Karma to run the tests.
__karma__.start();
Upvotes: 2
Reputation: 8936
If you're sure that you have spec.ts files in your path, this is the only difference I see between your karma.config and mine:
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular-devkit/build-angular/plugins/karma')
],
Mine didn't have the files:
at all before I looked at this question though, so you could also try just removing it.
Upvotes: 2