karma-runner / karma-runner/karma
Karma unable to find aliases. "Cannot find module..."
- Dominant language
- JavaScript
- Stars
- 12k
- Forks
- 1.7k
- PR merge metrics
- No merged PRs in 30d
Description
Hi everyone! I am new to using karma and was wondering if anyone knows how to defina aliases in karma.
### Actual behaviour
When I run karma start, I get an error saying:
``Uncaught Error: Cannot find module "@angular/core"
at build/StartPage-bundle.js:15165``
### Environment Details
karma-requirejs@^1.1.0
// Karma configuration
// Generated on Fri May 29 2015 21:48:48 GMT+0200 (CEST)
var webpackConfig = require('./webpack.config.js');
module.exports = function (config) {
config.set({
webpack: webpackConfig,
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine'],
// list of files / patterns to load in the browser
files: [
"libs/requirejs/require-2.1.15.js",
"libs/angular/angular-1.5.8.js",
"miniapp/common/ng2Core.js",
"build/shared-bundle.js",
"build/test/webapi-test-bundle.js",
"build/LegalNotice-bundle.js",
"build/*.js",
"build/test/*.js",
//{ pattern: 'miniapp/dataModel/test/-dataModel.tests.js', watched: false }
],
// list of files to exclude
exclude: [
],
plugins: [
"jasmine-core",
"karma-chrome-launcher",
"karma-jasmine",
"karma-jasmine-jquery",
"karma-mocha-reporter",
"karma-phantomjs-launcher",
"karma-requirejs",
"karma-webpack"
],
// proxies: {
// "@angular/core": "./miniapp/common/ng2Core"
// },
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
"build/*.js": ['webpack'],
"build/test/*.js": ['webpack']
},
webpack: {
module: webpackConfig.module,
resolve: webpackConfig.resolve
},
webpackMiddleware: {
// webpack-dev-middleware configuration
// i. e.
stats: 'errors-only'
},
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['mocha'],
// web server port
port: 9876,
// enable / disable colors in the output (reporters and logs)
colors: true,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: false,
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['Chrome'],
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: true,
// Concurrency level
// how many browser should be started simultaneous
concurrency: Infinity
})
}
``
Contributor guide
Research direction
Start with webpack.config.js and the Karma configuration, then reproduce the issue with `karma start`; inspect how build/StartPage-bundle.js resolves `@angular/core`. Done means the configured aliases resolve during the Karma run without the “Cannot find module” error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- angular, javascript, webpack
- Domain
- build-system, testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100