stryker-mutator / stryker-karma-runner Goto Github PK
View Code? Open in Web Editor NEWA plugin to use the karma test runner in Stryker, the JavaScript mutation testing framework
A plugin to use the karma test runner in Stryker, the JavaScript mutation testing framework
In order to support things like karma preprocessors we should run child processes from their respective sandbox folder. I tested stryker with a karma preprocessor here: https://github.com/nicojs/karma-preprocessor-stryker-test and it doesn't work.
Error Can not load "webpack"
arguments[i].apply is not a function
Can't load webpack options from karmaConfig from stryker config.
Error happens only if any plugin is added.
How to reproduce:
git clone https://github.com/unlight/angular-webpack-seed
cd angular-webpack-seed
git checkout bug-1
npm i
npm run stryker -q
Expected behaviour:
No errors
Actual:
[2017-04-20 13:12:34.248] [TRACE] IsolatedTestRunnerAdapter - 20 04 2017 13:12:34.241:
ERROR [preprocess]: Can not load "webpack"!
TypeError: arguments[i].apply is not a function
at Compiler.apply (d:\Dev\angular-webpack-seed\node_modules\tapable\lib\Tapable.js:310:16)
at webpack (d:\Dev\angular-webpack-seed\node_modules\webpack\lib\webpack.js:32:19)
at new Plugin (d:\Dev\angular-webpack-seed\node_modules\karma-webpack\lib\karma-webpack.js:69:15)
at invoke (d:\Dev\angular-webpack-seed\node_modules\di\lib\injector.js:75:15)
at Array.instantiate (d:\Dev\angular-webpack-seed\node_modules\di\lib\injector.js:59:20)
at get (d:\Dev\angular-webpack-seed\node_modules\di\lib\injector.js:48:43)
at d:\Dev\angular-webpack-seed\node_modules\di\lib\injector.js:71:14
at Array.map (native)
at Array.invoke (d:\Dev\angular-webpack-seed\node_modules\di\lib\injector.js:70:31)
at Injector.get (d:\Dev\angular-webpack-seed\node_modules\di\lib\injector.js:48:43)
at instantiatePreprocessor (d:\Dev\angular-webpack-seed\node_modules\karma\lib\preprocessor.js:55:20)
at Array.forEach (native)
at createPreprocessor (d:\Dev\angular-webpack-seed\node_modules\karma\lib\preprocessor.js:74:20)
at Array.invoke (d:\Dev\angular-webpack-seed\node_modules\di\lib\injector.js:75:15)
at get (d:\Dev\angular-webpack-seed\node_modules\di\lib\injector.js:48:43)
at d:\Dev\angular-webpack-seed\node_modules\di\lib\injector.js:71:14
Env:
windows 10
node v7.9.0
part of stryker config:
karmaConfig: {
preprocessors: {
'**/spec.module.js': ['webpack'],
},
browsers: ['Nightmare'],
webpack: {
module: {
exprContextCritical: false,
rules: [
{
test: /\.component\.html$/,
use: [
{ loader: 'raw-loader' }
]
},
{
test: /\.component\.scss$/,
use: [
{ loader: 'raw-loader' },
{ loader: 'sass-loader' },
]
},
{
test: /\.component\.[tj]s$/,
use: [
{ loader: 'angular2-template-loader' }
]
}
]
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('development')
}),
// new webpack.DllReferencePlugin({
// context: context,
// manifest: require(libs)
// })
]
}
},
http://karma-runner.github.io/1.0/config/configuration-file.html
Karma config file can be ./karma.conf.ts
stryker-karma-runner uses simple require
Map file types to modules are listed here
https://github.com/js-cli/js-interpret
A lot of users expect karma.conf.js
settings to be mirrored in stryker. We should add this feature using the ConfigWriter interface.
We should either completely remove the current karmaConfig
overrides method and only except a string, or we should support both a string (location of the karma.conf.js
file). @simondel which one would you prefer?
In order for this to work stryker-mutator/stryker-js#148 needs to be fixed as well. Otherwise the current working directory would not be in sync with all preprocessor paths and such.
Hi, I'm trying to use stryker on a project I'm working on, I tried first using it in a simple application that I have to test things like this, and it worked perfectly so I decided to apply it to a bigger project, this bigger project uses Webpack, below I'll paste my three configurations, stryker, karma and webpack and also the error I get.
stryker.conf.js:
module.exports = function(config){
config.set({
testRunner: 'karma',
testFramework: 'jasmine',
karmaConfigFile: 'karma.conf.js',
logLevel: 'trace',
reporter: [
'progress',
'clear-text',
'dots',
'html',
'event-recorder'
],
coverageAnalysis: 'perTest',
plugins: [
'stryker-jasmine',
'stryker-karma-runner',
'stryker-html-reporter'
]
});
}
karma.conf.js:
'use strict';
var webpackConfig = require('./webpack/webpack.config.test.js');
require('phantomjs-polyfill');
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: false,
browsers: ['PhantomJS'],
singleRun: true,
autoWatchBatchDelay: 300,
files: [
'./node_modules/phantomjs-polyfill/bind-polyfill.js',
'./src/test.index.ts'
],
babelPreprocessor: {
options: {
presets: ['es2015']
}
},
preprocessors: {
'src/test.index.ts': ['webpack']
},
webpackMiddleware: {
stats: {
chunkModules: false,
colors: true
}
},
webpack: webpackConfig
});
};
webpack.config.test.js:
var webpack = require('webpack');
var path = require('path');
var loaders = require("./webpack.config.common");
var ExtractTextPlugin = require('extract-text-webpack-plugin');
const ENV = process.env.ENV = process.env.NODE_ENV = 'test';
module.exports = {
entry: null,
output: {
filename: '[name]-[hash].js',
path: path.resolve(__dirname, '../tmp')
},
resolve: {
modules: [
path.join(__dirname, "../src"),
'node_modules'
],
extensions: ['.ts', '.js', '.json', '.css', '.scss', '.sass']
},
devtool: "source-map-inline",
plugins: [
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery',
'window.jquery': 'jquery'
}),
new ExtractTextPlugin('[name]-[contenthash].css')
],
module: {
rules: loaders
}
};
Error Code:
[2017-03-31 11:17:25.727] [TRACE] IsolatedTestRunnerAdapter - 31 03 2017 11:17:25.724:ERROR [preprocess]: Can not load "webpack"!
TypeError: arguments[i].apply is not a function
at Compiler.apply (<ProjectPath>/node_modules/tapable/lib/Tapable.js:306:16)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.