Cannot run ng test Jasmine missing and karma does not match any files
Bug Report or Feature Request (mark with an x)
- [x ] bug report -> please search issues before submitting
- [ ] feature request
Versions.
@angular/cli: 1.2.1
node: 8.1.4
os: win32 x64
"dependencies": {
"@angular/animations": "^4.0.0",
"@angular/common": "^4.0.0",
"@angular/compiler": "^4.0.0",
"@angular/core": "^4.0.0",
"@angular/forms": "^4.0.0",
"@angular/http": "^4.0.0",
"@angular/platform-browser": "^4.0.0",
"@angular/platform-browser-dynamic": "^4.0.0",
"@angular/router": "^4.0.0",
"core-js": "^2.4.1",
"rxjs": "^5.1.0",
"zone.js": "^0.8.4"
},
"devDependencies": {
"@angular/cli": "1.2.1",
"@angular/compiler-cli": "^4.0.0",
"@angular/language-service": "^4.0.0",
"@types/jasmine": "~2.5.53",
"@types/jasminewd2": "~2.0.2",
"@types/node": "~6.0.60",
"codelyzer": "~3.0.1",
"jasmine-core": "~2.6.2",
"jasmine-spec-reporter": "~4.1.0",
"karma": "~1.7.0",
"karma-chrome-launcher": "~2.1.1",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.2",
"ts-node": "~3.0.4",
"tslint": "~5.3.2",
"typescript": "~2.3.3"
}
Repro steps.
i have installed newest node version and cli version
- create new angular project with ng new command
- npm install (as angular cli "1.2.1" version does not install node modules while creating new project)
- run ng test
The log given by the failure.
D:\[angularPractice]\newtestproj>ng test
10% building modules 1/1 modules 0 active19 07 2017 18:45:26.075:WARN [watcher]: Pattern "D:\[angularPractice]\newtestproj\node_modules\jasmine-core\lib/jasmine-core/jasmine.js" does not
match any file.
19 07 2017 18:45:26.082:WARN [watcher]: Pattern "D:\[angularPractice]\newtestproj\node_modules\karma-jasmine\lib\boot.js" does not match any file.
19 07 2017 18:45:26.084:WARN [watcher]: Pattern "D:\[angularPractice]\newtestproj\node_modules\karma-jasmine\lib\adapter.js" does not match any file.
19 07 2017 18:45:26.084:WARN [watcher]: Pattern "D:\[angularPractice]\newtestproj\node_modules\karma-jasmine-html-reporter\src/css/jasmine.css" does not match any file.
19 07 2017 18:45:26.085:WARN [watcher]: Pattern "D:\[angularPractice]\newtestproj\node_modules\karma-jasmine-html-reporter\src/lib/html.jasmine.reporter.js" does not match any file.
19 07 2017 18:45:26.086:WARN [watcher]: Pattern "D:\[angularPractice]\newtestproj\node_modules\karma-jasmine-html-reporter\src/lib/adapter.js" does not match any file.
19 07 2017 18:45:26.090:WARN [karma]: No captured browser, open http://localhost:9876/
19 07 2017 18:45:26.205:INFO [karma]: Karma v1.7.0 server started at http://0.0.0.0:9876/
19 07 2017 18:45:26.206:INFO [launcher]: Launching browser Chrome with unlimited concurrency
19 07 2017 18:45:26.242:INFO [launcher]: Starting browser Chrome
19 07 2017 18:45:42.162:WARN [watcher]: Pattern "D:\[angularPractice]\newtestproj\node_modules\jasmine-core\lib/jasmine-core/jasmine.js" does not match any file.
19 07 2017 18:45:42.163:WARN [watcher]: Pattern "D:\[angularPractice]\newtestproj\node_modules\karma-jasmine\lib\boot.js" does not match any file.
19 07 2017 18:45:42.163:WARN [watcher]: Pattern "D:\[angularPractice]\newtestproj\node_modules\karma-jasmine\lib\adapter.js" does not match any file.
19 07 2017 18:45:42.184:WARN [watcher]: Pattern "D:\[angularPractice]\newtestproj\node_modules\karma-jasmine-html-reporter\src/css/jasmine.css" does not match any file.
19 07 2017 18:45:42.185:WARN [watcher]: Pattern "D:\[angularPractice]\newtestproj\node_modules\karma-jasmine-html-reporter\src/lib/html.jasmine.reporter.js" does not match any file.
19 07 2017 18:45:42.186:WARN [watcher]: Pattern "D:\[angularPractice]\newtestproj\node_modules\karma-jasmine-html-reporter\src/lib/adapter.js" does not match any file.
19 07 2017 18:45:42.189:WARN [karma]: No captured browser, open http://localhost:9876/
19 07 2017 18:45:53.516:INFO [Chrome 61.0.3159 (Windows 8.1 0.0.0)]: Connected on socket auPEGyLWa0itMxb2AAAA with id 4588292
Chrome 61.0.3159 (Windows 8.1 0.0.0) ERROR
Uncaught Error: Missing: jasmine.js
at http://localhost:9876/_karma_webpack_/vendor.bundle.js:3048
Chrome 61.0.3159 (Windows 8.1 0.0.0) ERROR
Uncaught Error: Missing: jasmine.js
at http://localhost:9876/_karma_webpack_/vendor.bundle.js:3048
Desired functionality.
Do i have to any thing different for all the steps that i have taken. i want simple ng test to run.
Mention any other details that might be useful.
I am also attaching the karma out window with console

karma config file details
// 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', '@angular/cli'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular/cli/plugins/karma')
],
client:{
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
reports: [ 'html', 'lcovonly' ],
fixWebpackSourcePaths: true
},
angularCli: {
environment: 'dev'
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false
});
};
test.ts file details
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
import 'zone.js/dist/long-stack-trace-zone';
import 'zone.js/dist/proxy.js';
import 'zone.js/dist/sync-test';
import 'zone.js/dist/jasmine-patch';
import 'zone.js/dist/async-test';
import 'zone.js/dist/fake-async-test';
import { getTestBed } from '@angular/core/testing';
import {
BrowserDynamicTestingModule,
platformBrowserDynamicTesting
} from '@angular/platform-browser-dynamic/testing';
// Unfortunately there's no typing for the `__karma__` variable. Just declare it as any.
declare const __karma__: any;
declare const require: any;
// Prevent Karma from running prematurely.
__karma__.loaded = function () { };
// First, initialize the Angular testing environment.
getTestBed().initTestEnvironment(
BrowserDynamicTestingModule,
platformBrowserDynamicTesting()
);
// Then we find all the tests.
const context = require.context('./', true, /\.spec\.ts$/);
console.log(context);
// And load the modules.
context.keys().map(context);
// Finally, start Karma to run the tests.
__karma__.start();
file structure
it was related to the file path i name folder with "[floder name]" it was a mistake
Thanks @Bsujeet , For All windows users: I got the same issue as @Bsujeet , and resolved by deleting extra spaces from all folders into the path name, Hope this help (may it should be considered in the next versions of angular cli) :)
@meksof I am having the same issue, I am not sure what you mean by deleting extra spaces from all folders in the path name.
Looking forward to your response.
@AliF50 make sure your project root folder to be as "project_name" not as "project name"
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.
Similar: #38377