Skip to content

Instantly share code, notes, and snippets.

@philipjfulcher
Created April 17, 2020 20:10
Show Gist options
  • Save philipjfulcher/e20c41993c45b51bb797812ed0d667d2 to your computer and use it in GitHub Desktop.
Save philipjfulcher/e20c41993c45b51bb797812ed0d667d2 to your computer and use it in GitHub Desktop.
Example Karma config for AngularJS in nx
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html
// reuse webpack config
const webpack = require('./webpack.config');
const getBaseKarmaConfig = require('../../karma.conf');
module.exports = function(config) {
const baseConfig = getBaseKarmaConfig();
config.set({
...baseConfig,
frameworks: ['jasmine'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('karma-webpack')
],
// This will be the new entry to webpack
// so it should just be a single file
files: ['src/test.js'],
// Preprocess test index and test files using
// webpack (will run babel)
preprocessors: {
'src/test.js': ['webpack'],
'src/**/*.spec.js': ['webpack']
},
// Reference webpack config (single object)
// and configure some middleware settings
webpack: {
...webpack({}),
mode: 'development'
},
webpackMiddleware: {
noInfo: true,
stats: 'errors-only'
},
// Typical Karma settings, see docs
reporters: ['progress'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['ChromeHeadless'],
singleRun: true,
concurrency: Infinity
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment