You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using karma-requirejs for testing Node-Express project. But I am getting below error when doing npm test. Can anyone help me on this?
{ "message": "Uncaught Error: Module name \"http-errors\" has not been loaded yet for context: _. Use require([])\nhttp://requirejs.org/docs/errors.html#notloaded\nat node_modules/requirejs/require.js:143:9\n\nError: Module name \"http-errors\" has not been loaded yet for context: _. Use require([])\nhttp://requirejs.org/docs/errors.html#notloaded\n at makeError (node_modules/requirejs/require.js:168:17)\n at Object.localRequire [as require] (node_modules/requirejs/require.js:1436:44)\n at requirejs (node_modules/requirejs/require.js:1797:24)\n at app.js:1:19", "str": "Uncaught Error: Module name \"http-errors\" has not been loaded yet for context: _. Use require([])\nhttp://requirejs.org/docs/errors.html#notloaded\nat node_modules/requirejs/require.js:143:9\n\nError: Module name \"http-errors\" has not been loaded yet for context: _. Use require([])\nhttp://requirejs.org/docs/errors.html#notloaded\n at makeError (node_modules/requirejs/require.js:168:17)\n at Object.localRequire [as require] (node_modules/requirejs/require.js:1436:44)\n at requirejs (node_modules/requirejs/require.js:1797:24)\n at app.js:1:19" }
Hi,
I am using karma-requirejs for testing Node-Express project. But I am getting below error when doing npm test. Can anyone help me on this?
{ "message": "Uncaught Error: Module name \"http-errors\" has not been loaded yet for context: _. Use require([])\nhttp://requirejs.org/docs/errors.html#notloaded\nat node_modules/requirejs/require.js:143:9\n\nError: Module name \"http-errors\" has not been loaded yet for context: _. Use require([])\nhttp://requirejs.org/docs/errors.html#notloaded\n at makeError (node_modules/requirejs/require.js:168:17)\n at Object.localRequire [as require] (node_modules/requirejs/require.js:1436:44)\n at requirejs (node_modules/requirejs/require.js:1797:24)\n at app.js:1:19", "str": "Uncaught Error: Module name \"http-errors\" has not been loaded yet for context: _. Use require([])\nhttp://requirejs.org/docs/errors.html#notloaded\nat node_modules/requirejs/require.js:143:9\n\nError: Module name \"http-errors\" has not been loaded yet for context: _. Use require([])\nhttp://requirejs.org/docs/errors.html#notloaded\n at makeError (node_modules/requirejs/require.js:168:17)\n at Object.localRequire [as require] (node_modules/requirejs/require.js:1436:44)\n at requirejs (node_modules/requirejs/require.js:1797:24)\n at app.js:1:19" }
package.json
"scripts": { "start": "node ./bin/www", "test": "karma start & karma run" }, "dependencies": { "browserify": "^16.2.0", "cookie-parser": "~1.4.3", "debug": "~2.6.9", "express": "~4.16.0", "http-errors": "^1.6.3", "jade": "~1.11.0", "morgan": "~1.9.0", "mysql": "^2.15.0", "sqlite3": "^4.0.0", "watchify": "^3.11.0" }, "devDependencies": { "jasmine-core": "~2.8.0", "jasmine-spec-reporter": "~4.2.1", "karma": "^2.0.2", "karma-browserify": "^5.2.0", "karma-chrome-launcher": "~2.2.0", "karma-coverage-istanbul-reporter": "^1.2.1", "karma-jasmine": "~1.1.0", "karma-jasmine-html-reporter": "^0.2.2", "karma-phantomjs-launcher": "^1.0.4", "karma-requirejs": "^1.1.0", "karma-webpack": "^3.0.0", "requirejs": "^2.3.5", "webpack": "^4.6.0", "webpack-node-externals": "^1.7.2" }
karma.conf.js
`// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html
const nodeExternals = require('webpack-node-externals');
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', 'requirejs'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
//require('karma-phantomjs-launcher'),
//require('karma-jasmine-html-reporter'),
//require('karma-coverage-istanbul-reporter'),
require('karma-requirejs')
],
files: [
'test-main.js',
'app.js',
{pattern: 'routes/.js', included: false},
{pattern: 'spec/.spec.js', included: false},
};`
The text was updated successfully, but these errors were encountered: