aurelia / testing

Simplifies the testing of UI components by providing an elegant, fluent interface for arranging test setups along with a number of runtime debug/test helpers.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Typescript and Karma

rinobatin opened this issue · comments

I have a project based on aurelia skeleton-typescript-asp.net5 which is using Typescript.

The folder structure looks like this:

src/
wwwroot/
       dist
test/
     unit/sample.spec.ts

I have a test (sample.spec.ts) with StageComponent.withResources('../../src/component').... When I run karma, I get an 404 error because it could find http://localhost:9876/src/component.js. This js file is in wwwroot/dist which gets created during transpilation. I prefer the TS transpiled on the fly.

One solution is like this: StageComponent.withResources('/base/src/component.ts').

Is there a better way to solve this problem?

Check your karma config paths and see if they match what we have in the latest version of the skeleton in master. There have been some changes there recently that improve a number of issues like this.

@EisenbergEffect, I don't think its the Karma config (I check my copy and its almost identical with the latest). Besides, the original tests from the skeleton are passing.

With the latest skeleton config, I think that StageComponent.withResources('component') should work. Have you tried that?

StageComponent.withResources('component') give me this error:

'Potentially unhandled rejection [4] Error: XHR error (404 Not Found) loading http://localhost:9876/base/component.js
    at o (http://localhost:9876/base/node_modules/systemjs/dist/system.js?ea2d7cecbce9a5de1b6777fa755578976b7f3e2b:4:12694)
    at XMLHttpRequest.s.onreadystatechange (http://localhost:9876/base/node_modules/systemjs/dist/system.js?ea2d7cecbce9a5de1b6777fa755578976b7f3e2b:4:13219)'

I will fork the skeleton and reproduce this problem. I'll post the link.

I found the problem -- it's the path that I used in the withResources.

Given the folder structure above, it should be StageComponent.withResources('src/component')