Larchy Larchy - 1 year ago 151
TypeScript Question

Karma + JSPM + Typescript - not found '.ts.js'

Mainly just trying to get Karma+JSPM to play nice on loading the .ts files but having absolutely no luck.

I see up a discussion repo with a stripped down example.

Basically JSPM within Karma is seemingly ignoring the

defaultJSExtensions: true
and package level
"defaultExtension": "ts"
configurations when running in Karma giving the following error when attempting to load files:

$ npm test

> karma-jspm-typescript-coverage@1.0.0 test C:\examples\karma-jspm-typescript-coverage
> karma start

18 08 2016 17:29:31.937:INFO [karma]: Karma v1.2.0 server started at http://localhost:1337/
18 08 2016 17:29:31.943:INFO [launcher]: Launching browser Chrome with unlimited concurrency
18 08 2016 17:29:31.974:INFO [launcher]: Starting browser Chrome
18 08 2016 17:29:33.075:INFO [Chrome 52.0.2743 (Windows 7 0.0.0)]: Connected on socket /#jTR10wm0CWNIfrdhAAAA with id 75197348
18 08 2016 17:29:33.317:WARN [web-server]: 404: /src/app/app.spec.ts.js
Chrome 52.0.2743 (Windows 7 0.0.0) ERROR
Error: (SystemJS) XHR error (404 Not Found) loading http://localhost:1337/src/app/app.spec.ts.js
Error: XHR error (404 Not Found) loading http://localhost:1337/src/app/app.spec.ts.js
Error loading http://localhost:1337/src/app/app.spec.ts.js

npm ERR! Test failed. See above for more details.

Note the .ts.js extension. Tried everyting from karma-typescript-proprocessor to loading via a different JSPM config than what would be ran with live.

Trying to keep it so there's no need to manage the
compiled files and only work with the
files. The development server and bundling/build are fully functional - this testing and coverage piece is my last hurdle.

Please let me know if there any kind of direction you can give me!

Answer Source

package level "defaultExtension": "ts" does not apply because karma is running in the top-level directory, one level above src directory which contains config.js with

baseURL: '.'

If I duplicate app package config there with src prepended to it, like this:

  packages: {
    "src/app": {
      "main": "app",
      "defaultExtension": "ts",
      "meta": {
        "*.ts": {
          "loader": "ts"
    "app": {
      "main": "app",
      "defaultExtension": "ts",
      "meta": {
        "*.ts": {
          "loader": "ts"

I'm able to get one step further. I'm now getting

Error: (SystemJS) XHR error (404 Not Found) loading http://localhost:9876/jspm_packages/github/frankwallis/plugin-typescript@5.0.9.js

which indicates to me that karma-jspm plugin is unable to serve source files at URLs where SystemJS expects them to be

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download