angular-cli: Cannot run tests using Chrome Dev v55
- 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)
- 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
- 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
- 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
- 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)
Links to this issue
Commits related to this issue
- Fix(config):Add MIME type to work around Chrome > 54 problem (#2125) — committed to jtsom/angular-cli by jtsom 8 years ago
- fix(test):add ts MIME type Fix #2125 Close #2175 — committed to angular/angular-cli by jtsom 8 years ago
- set mime type for karma https://github.com/angular/angular-cli/issues/2125#issuecomment-247395088 — committed to PRX/publish.prx.org by deleted user 8 years ago
- Fix MIME type ('text/x-typescript') https://github.com/angular/angular-cli/issues/2125#issuecomment-247395088 ``` Refused to execute script from 'http://localhost:9876/base/test/browser/sub_test.ts'... — committed to arosh/karma-power-assert-typescript-mocha-webpack-sample by arosh 8 years ago
- fix issue : https://github.com/angular/angular-cli/issues/2125#issuecomment-247395088 — committed to GeoHealth/HAppi_mobile by seza443 8 years ago
- change to specify mime type for chrome dev v55 compatibility. see https://github.com/angular/angular-cli/issues/2125 — committed to ebeer/angular2-tdd-examples by deleted user 7 years ago
- fix(test):add ts MIME type Fix #2125 Close #2175 — committed to MRHarrison/angular-cli by jtsom 8 years ago
- fixes `npm test` due to a bug in chrome, see https://github.com/angular/angular-cli/issues/2125 — committed to JohannesHoppe/angular-date-value-accessor by JohannesHoppe 7 years ago
I figured out a work around. In the karma.conf.js file, add:
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.