1

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:

  • the patterns contain backslashes (I'm using Windows 10), but at the end the normal slashes are used (example: my-project\node_modules\jasmine-core\lib/jasmine-core/jasmine.js). This might be the problem.
  • The Chrome error says that the jasmine.js file is missing so I think this has something to do with the patterns.
  • I tried to change the basePath in the karma.config.js file but it didn't help

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?

1 Answer 1

2

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!

Sign up to request clarification or add additional context in comments.

1 Comment

Same problem here, thank you for posting your solution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.