J4K03
J4K03

Reputation: 31

Angular Karma Throws Uncaught Error: Missing jasmine.js

I've created a new angular project and wanted to run tests with ng test. But I'm getting a lot of Pattern ** does not match any file errors.

The launched chrome window remains blank and I'm getting an uncaught Chrome error: Missing jasmine.js.

Simplified console output:

my-project>ng test
WARN [watcher]: Pattern "my-project\node_modules\jasmine-core\lib/jasmine-core/jasmine.js" does not match any file.
WARN [watcher]: Pattern "my-project\node_modules\karma-jasmine\lib\boot.js" does not match any file.
WARN [watcher]: Pattern "my-project\node_modules\karma-jasmine\lib\adapter.js" does not match any file.
WARN [watcher]: Pattern "my-project\node_modules\karma-jasmine-html-reporter\src/css/jasmine.css" does not match any file.
WARN [watcher]: Pattern "my-project\node_modules\karma-jasmine-html-reporter\src/lib/html.jasmine.reporter.js" does not match any file.
WARN [watcher]: Pattern "my-project\node_modules\karma-jasmine-html-reporter\src/lib/adapter.js" does not match any file.
WARN [karma]: No captured browser, open http://localhost:9876/
INFO [karma-server]: Karma v3.1.4 server started at http://0.0.0.0:9876/
INFO [launcher]: Launching browsers Chrome with concurrency unlimited
INFO [launcher]: Starting browser Chrome                                                                    
INFO [Chrome 73.0.3683 (Windows 10.0.0)]: Connected on socket 1nrITWT6uMuWp44pAAAA with id 90148583
Chrome 73.0.3683 (Windows 10.0.0) ERROR
  {
    "message": "Uncaught Error: Missing: jasmine.js
    at http://localhost:9876/_karma_webpack_/vendor.js:84510:9

    Error: Missing: jasmine.js
       at http://localhost:9876/_karma_webpack_/vendor.js:84510:15
       at http://localhost:9876/_karma_webpack_/vendor.js:84728:3
       at http://localhost:9876/_karma_webpack_/vendor.js:84118:10
       at Object.<anonymous>(http://localhost:9876/_karma_webpack_/vendor.js:84120:2)
       at Object../node_modules/zone.js/dist/zone-testing.js (http://localhost:9876/_karma_webpack_/vendor.js:85694:30)
        at __webpack_require__ (http://localhost:9876/_karma_webpack_/main.js:79:30)
       at Module../src/test.ts (http://localhost:9876/_karma_webpack_/main.js:355:83)
       at __webpack_require__ (http://localhost:9876/_karma_webpack_/main.js:79:30)
       at checkDeferredModules (http://localhost:9876/_karma_webpack_/main.js:46:23)
       at http://localhost:9876/_karma_webpack_/main.js:152:18"
  }

My karma.conf.js file:

module.exports = function (config) {
  config.set({
    basePath: '.',
    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')
    ],
    client: {
      clearContext: false // leave Jasmine Spec Runner output visible in browser
    },
    coverageIstanbulReporter: {
      dir: require('path').join(__dirname, '../coverage/my-project'),
      reports: ['html', 'lcovonly', 'text-summary'],
      fixWebpackSourcePaths: true
    },
    reporters: ['progress', 'kjhtml'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ['Chrome'],
    singleRun: false
  });
};

What I figured out and tried to do:

I'm pretty new to this whole testing topic and I don't know how to fix this error. What do I have to change?

Upvotes: 1

Views: 1708

Answers (1)

J4K03
J4K03

Reputation: 31

Ok after a bit of further searching for the problem I've found out that my path to my project was invalid for karma somehow: F:\Projects\2019.04.05 - 2019.04.08[Angular] My Project\my-project

The characters that caused the problem were the squared brackets [ ]

Now everything works!

Upvotes: 2

Related Questions