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

Could not find any modules. Did you remember to set 'preprocessors' in your Karma config? #51

Open
hrietman opened this issue Mar 8, 2016 · 4 comments

Comments

@hrietman
Copy link

hrietman commented Mar 8, 2016

Followed the configuration in the read me but I am getting the following error:

Error: Could not find any modules. Did you remember to set 'preprocessors' in your Karma config?
  at /Development/codecentric/angular2-hamis-seed/node_modules/karma-commonjs/client/commonjs_bridge.js:5
basePath: '',

        frameworks: ['jasmine', 'commonjs'],
        browsers: ['PhantomJS'],
        reporters: ['progress', 'coverage'],

        preprocessors: {
            'app/**/!(*.spec)+(.js)': ['coverage'],
            'app/**/*.js': ['sourcemap'],
            'app/**/*.js': ['commonjs']
        },

        commonjsPreprocessor: {
            modulesRoot: 'node_modules'
        },

I also tried setting the commonjs Preprocessor option but did not help.

Part of the config:

Any idea's?

@jamesshore
Copy link
Contributor

Did you set the files option?

@hrietman
Copy link
Author

hrietman commented Mar 9, 2016

Yes I did,

files: [
            // paths loaded by Karma
            {pattern: 'node_modules/es6-shim/es6-shim.min.js', included: true, watched: true},
            {pattern: 'node_modules/systemjs/dist/system-polyfills.js', included: true, watched: true},

            {pattern: 'node_modules/systemjs/dist/system.src.js', included: true, watched: true},
            {pattern: 'node_modules/rxjs/bundles/Rx.js', included: true, watched: true},
            {pattern: 'node_modules/reflect-metadata/temp/Reflect.js', included: true, watched: true},
            {pattern: 'node_modules/angular2/bundles/angular2.js', included: true, watched: true},
            {pattern: 'node_modules/angular2/bundles/testing.dev.js', included: true, watched: true},
            {pattern: 'node_modules/angular2/bundles/http.dev.js', included: true, watched: true},
            {pattern: 'karma-test-shim.js', included: true, watched: true},
           // {pattern: 'src/test/matchers.js', included: true, watched: true},

            // paths loaded via module imports
            {pattern: 'src/**/*.js', included: false, watched: true},

            // paths loaded via Angular's component compiler
            // (these paths need to be rewritten, see proxies section)
            {pattern: 'src/**/*.html', included: false, watched: true},
            {pattern: 'src/**/*.css', included: false, watched: true},

            // paths to support debugging with source maps in dev tools
            {pattern: 'src/**/*.ts', included: false, watched: false},
            {pattern: 'src/**/*.js.map', included: false, watched: false},

            {pattern: 'test/karma/specs/**/*.js', included: false, watched: false},

        ],

Reading up on the other issues, it seems it has to do with dependencies on modules in the node_modules folder.

@brandonros
Copy link

Any updates @hrietman ?

@hrietman
Copy link
Author

hrietman commented Feb 18, 2017

@brandonros This is almost a year ago; I since moved on with Angular-cli to setup projects; however here is my current karma configuration, maybe it helps you further:

`

module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', 'angular-cli'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-phantomjs-launcher'),
require('karma-remap-istanbul'),
require('angular-cli/plugins/karma'),
require("karma-spec-reporter")
],
files: [
{pattern: './src/test.ts', watched: false}
],
preprocessors: {
'./src/test.ts': ['angular-cli']
},
mime: {
'text/x-typescript': ['ts', 'tsx']
},
remapIstanbulReporter: {
reports: {
html: 'coverage',
lcovonly: './coverage/coverage.lcov'
}
},
angularCli: {
config: './angular-cli.json',
environment: 'dev'
},
specReporter: {
maxLogLines: 5, // limit number of lines logged per test
suppressErrorSummary: true, // do not print error summary
suppressFailed: false, // do not print information about failed tests
suppressPassed: false, // do not print information about passed tests
suppressSkipped: true, // do not print information about skipped tests
showSpecTiming: false // print the time elapsed for each spec
},
reporters: config.angularCli && config.angularCli.codeCoverage
? ['spec', 'karma-remap-istanbul']
: ['spec'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: false,
browsers: ['PhantomJS'],
singleRun: true,
browserNoActivityTimeout: 60000
});
};
`

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

3 participants