Search code examples
typescriptkarma-jasmineaureliajspm

Staging a component for testing


Executing the app and loading views with @useview('resources/panels/data-table-panel.html') works, but running a component test fails. Caused by 404 html-file not found.

By changing the path to @useview('src/resources/panels/data-table-panel.html') the component can be staged, which the leads to a 404 if the app gets started later by serving it with gulp.

Custom Component

Staging the component

File Tree

Karma Conf

Does anybody have an idea how to workaround this problem? thx


Solution

  • I never tried the jspm skeleton. It's quite outdated, I recommend you to create a new project with latest aurelia-cli, then migrate source and test over.

    Speaking about the code itself, you can switch the absolute path to relative path:

    @useview('../path/to/resources/panels/data-table-panel.html')
    

    This should work. Relative path bypasses karma config on those absolute module resolution.


    I don't quite understand why the karma.config has following:

    paths: {
              "*": "*",
              "src/*": "src/*",
    

    I thought it probably should be

    paths: {
              "*": "src/*",
    

    Then you have to remove all src/ prefix, like .withResources('resources/...').