Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Karma fails to run tests when using requirejs #60

Open
ngates87 opened this issue Oct 5, 2016 · 0 comments
Open

Karma fails to run tests when using requirejs #60

ngates87 opened this issue Oct 5, 2016 · 0 comments

Comments

@ngates87
Copy link

ngates87 commented Oct 5, 2016

I am running into a situation when using requirejs for my test, using the method provided here https://karma-runner.github.io/0.8/plus/RequireJS.html. I am encountering the following error(s), in VS Output ========== Discover test finished: 1 found (0:00:02.2382238) ========== ------ Run test started ------ An exception occurred while invoking executor 'executor://karmatestadapter/': One or more errors occurred. Value cannot be null. Parameter name: values ========== Run test finished: 0 run (0:00:00.1090109) ========== and in a browser (like chrome)
Error: Module name "../App/Password/password" has not been loaded yet for context: _. Use require([]) http://requirejs.org/docs/errors.html#notloaded require.js:165:17 load complete

my main.test.js ```var allTestFiles = [];
var TEST_REGEXP = /UnitTests/.*.js$/;

var pathToModule = function (path) {
var returnValue = path.replace(/^/base//, '').replace(/.js$/, '');
return returnValue;
};

Object.keys(window.karma.files).forEach(function (file) {
if (TEST_REGEXP.test(file)) {
// Normalize paths to RequireJS module names.
allTestFiles.push(pathToModule(file));
}
});

requirejs.config({
// Karma serves files from '/base'
baseUrl: '/base',

deps: allTestFiles,

paths: {
    'jquery.mockjax': 'Libraries/jquery.mockjax/jquery.mockjax'
},

shim: {
    'jquery.mockjax': {
        deps: ['jquery'],
        init: function (m) { }
    }
},

// start test run, once Require.js is done
callback: function () {
    console.log('load complete');
    window.__karma__.start();
}

});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant