Requirejs do not add “.js” for modules using karma

前端 未结 2 1767
余生分开走
余生分开走 2021-01-17 00:08

I have simple test, that must work in webstorm using karma and requirejs.

The problem is that for some reason requirejs do not add \".js\" for modules i was loading

2条回答
  •  情深已故
    2021-01-17 00:30

    It looks like trouble in require.js

    The problem is in next: 1. When in deps appear absolute path - requirejs stop add ".js" for any require call 2. When in deps appear file with extension, for some reason requirejs again stop add ".js" for modules

    Other Solution here - to replace bathUrl and add it to requirejs conf do not help.

    For me solution is next:

    var tests = Object.keys(window.__karma__.files).filter(function (file) {
        return (/\-jasmine\.js$/).test(file);
    }).map(function (file) {
        return file.replace(/^\/|\.js$/g, '');
    });
    

    and

    baseUrl: '',
    

    for requirejs.conf

    and i have no idea why requirejs still add "/base" for all url that are requested, but now all works fine

提交回复
热议问题