angular-cli: Cannot run tests using Chrome Dev v55

  1. OS? Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?)

OS: Windows 10 Version 1607 x64 Chrome: 55.0.2859.0 dev-m (64-bit)

  1. Versions. Please run ng --version. If there’s nothing outputted, please run in a Terminal: node --version and paste the result here:
$ node_modules/.bin/ng --version
angular-cli: 1.0.0-beta.14
node: 6.3.1
os: win32 x64
  1. Repro steps. Was this an app that wasn’t created using the CLI? What change did you do on your code? etc.
$ ng new my-project
$ cd my-project
$ ng test
  1. The log given by the failure. Normally this include a stack trace and some more information.

Console log:

15 09 2016 10:04:15.346:INFO [karma]: Karma v1.2.0 server started at http://localhost:9876/
15 09 2016 10:04:15.346:INFO [launcher]: Launching browser Chrome with unlimited concurrency
15 09 2016 10:04:15.369:INFO [launcher]: Starting browser Chrome
15 09 2016 10:04:16.826:INFO [Chrome 55.0.2859 (Windows 10 0.0.0)]: Connected on socket /#xqAYMg_-UhayckFyAAAA with id 24060829
Chrome 55.0.2859 (Windows 10 0.0.0): Executed 0 of 0 ERROR (0.002 secs / 0 secs)

Chrome console:

debug.html:1 Refused to execute script from 'http://localhost:9876/base/src/test.ts' because its MIME type ('video/mp2t') is not executable.
debug.js:6 Skipped 0 tests
  1. Mention any other details that might be useful.

I think this was probably caused by: https://codereview.chromium.org/2294283002 - is this a Chrome or angular-cli issue? Obviously .ts is a video container format in addition to the typescript format - so I assume that Chrome is blocking it because it thinks it’s a video file rather than a typescript file.

ng test worked fine in previous (non-webpack) betas with this version of Chrome, assumedly because test.ts was not injected into the runner.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 16 (6 by maintainers)

Commits related to this issue

Most upvoted comments

I figured out a work around. In the karma.conf.js file, add:

    mime: {
      'text/x-typescript': ['ts','tsx']
    },

This tells the Karma server to serve the .ts files with a text/x-typescript mime type. That seems to make it work.

It’s not an issue of angular-cli, it’s an issue of typescript/karma. I’m not using angular-cli, but this solution worked for me as well.