Socket
Socket
Sign inDemoInstall

@stryker-mutator/karma-runner

Package Overview
Dependencies
Maintainers
4
Versions
99
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stryker-mutator/karma-runner - npm Package Compare versions

Comparing version 4.1.2 to 4.2.0

11

CHANGELOG.md

@@ -6,2 +6,13 @@ # Change Log

# [4.2.0](https://github.io/stryker-mutator/stryker/compare/v4.1.2...v4.2.0) (2020-12-09)
### Features
* **karma-runner:** resolve local karma and ng version ([#2622](https://github.io/stryker-mutator/stryker/issues/2622)) ([5b92130](https://github.io/stryker-mutator/stryker/commit/5b921302787a526377be02a37eb43a487c8f283d))
## [4.1.2](https://github.io/stryker-mutator/stryker/compare/v4.1.1...v4.1.2) (2020-11-06)

@@ -8,0 +19,0 @@

12

package.json
{
"name": "@stryker-mutator/karma-runner",
"version": "4.1.2",
"version": "4.2.0",
"description": "A plugin to use the karma test runner in Stryker, the JavaScript mutation testing framework",

@@ -35,3 +35,3 @@ "main": "src/index.js",

"devDependencies": {
"@stryker-mutator/test-helpers": "4.1.2",
"@stryker-mutator/test-helpers": "4.2.0",
"@types/express": "~4.17.0",

@@ -48,7 +48,7 @@ "@types/node": "^14.0.1",

"peerDependencies": {
"@stryker-mutator/core": "~4.1.0"
"@stryker-mutator/core": "~4.2.0"
},
"dependencies": {
"@stryker-mutator/api": "4.1.2",
"@stryker-mutator/util": "4.1.2",
"@stryker-mutator/api": "4.2.0",
"@stryker-mutator/util": "4.2.0",
"decamelize": "~4.0.0",

@@ -70,3 +70,3 @@ "semver": "~6.3.0",

},
"gitHead": "8fea303c9994da0fce813b98f764761a57383f17"
"gitHead": "55071ce41ce0a6e1e3eb563c0bf3937a2d3e9f22"
}

@@ -11,138 +11,2 @@ [![Mutation testing badge](https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fstryker-mutator%2Fstryker%2Fmaster%3Fmodule%3Dkarma-runner)](https://dashboard.stryker-mutator.io/reports/github.com/stryker-mutator/stryker/master?module=karma-runner)

## Install
Install @stryker-mutator/karma-runner locally within your project folder, like so:
```bash
npm i --save-dev @stryker-mutator/karma-runner
```
## Bring your own test runner
The `@stryker-mutator/karma-runner` is a plugin for `stryker` to enable `karma` as a test runner.
However, it does *not* come packaged with it's own version of `karma`, instead it
uses *your very own karma* version. It can also work with `@angular/cli`, see [Configuring](#configuring)
**Note:** karma v2.0.3 has a [known issue](https://github.com/karma-runner/karma/issues/3057) which makes it impossible to use it with Stryker. please upgrade to 2.0.4 or higher.
## Configuring
You can configure the `@stryker-mutator/karma-runner` using the `stryker.conf.js` (or `stryker.conf.json`) config file.
```javascript
// Stryker.conf.js
module.exports = {
// ...
testRunner: 'karma',
// ...
karma: {
projectType: 'custom', // or 'angular-cli'
configFile: 'path/to/karma.conf.js', // default `undefined`
config: { // default `undefined`
browsers: ['ChromeHeadless'] // override config settings
}
}
}
```
### `karma.projectType` [`"custom"` | `"angular-cli"`]
Default: `"custom"`
Specify which kind of project you're using. This determines which command is used to start karma
* **`"custom"`**: configure @stryker-mutator/karma-runner to use `karma start`.
* **`"angular-cli"`**: configure @stryker-mutator/karma-runner to use `ng test` (see [configuring for angular-cli](#configure-angular-cli)).
### `karma.configFile` [`string`]
Default: `undefined`
Specify a ['karma.conf.js' file](http://karma-runner.github.io/2.0/config/configuration-file.html) to be loaded.
Options specified directly in your stryker.conf.js file using `karma.config` will overrule options in your karma.conf.js file.
### `karma.config` [`object`]
Default: `undefined`
Specify [karma configuration options](http://karma-runner.github.io/2.0/config/configuration-file.html) directly.
Options specified here will overrule any options in your karma.conf.js file.
### `karma.ngConfig.testArguments` [`object`]
Default: `undefined`
Add [ng test arguments](https://github.com/angular/angular-cli/wiki/test#options). For example, specify an alternative project with:
```js
karma: {
projectType: 'angular-cli',
ngConfig: {
testArguments: {
project: 'my-lib'
}
}
}
```
This will run ng test with `--project` argument: `ng test --project=my-lib`.
## Non overridable options
The browser's life cycle is determined by `@stryker-mutator/karma-runner`. I.e. these settings cannot be overridden:
```javascript
{
browserNoActivityTimeout: 1000000,
autoWatch: false,
singleRun: false,
detached: false
}
```
The `coverage` plugin will also be removed (not needed for mutation testing).
## Configure angular cli
**Note:** this requires v6.1.0-rc0 or higher of the [@angular/cli](https://www.npmjs.com/package/@angular/cli)
This is an example for a configuration of stryker using the angular cli:
```javascript
// stryker.conf.js
exports = function(config){
config.set({
// ...
karma: {
projectType: 'angular-cli',
karma: {
configFile: 'src/karma.conf.js'
},
ngConfig: {
// Override ng arguments here
testArguments: {
project: 'my-lib'
}
}
}
// ...
});
}
```
## Debugging
As Stryker runs karma in its own process, its logging output will be consumed by Stryker.
To see all logging from karma, set the log level to `trace` in `stryker.conf.js`.
```javascript
// stryker.conf.js
exports = function(config){
config.set({
// ...
logLevel: 'trace'
// ...
});
}
```
[See the Karma Runner's documentation on stryker-mutator.io](https://stryker-mutator.io/docs/stryker/karma-runner).

@@ -7,3 +7,3 @@ "use strict";

const semver = require("semver");
const utils_1 = require("../utils");
const util_1 = require("@stryker-mutator/util");
const MIN_ANGULAR_CLI_VERSION = '6.1.0';

@@ -14,3 +14,3 @@ async function start(getLogger, ngConfig) {

// Make sure require angular cli from inside this function, that way it won't break if angular isn't installed and this file is required.
let cli = utils_1.requireModule('@angular/cli');
let cli = util_1.requireResolve('@angular/cli');
if ('default' in cli) {

@@ -45,3 +45,4 @@ cli = cli.default;

function verifyAngularCliVersion() {
const version = semver.coerce(utils_1.requireModule('@angular/cli/package').version);
const pkg = util_1.requireResolve('@angular/cli/package');
const version = semver.coerce(pkg.version);
if (!version || semver.lt(version, MIN_ANGULAR_CLI_VERSION)) {

@@ -48,0 +49,0 @@ throw new Error(`Your @angular/cli version (${version}) is not supported. Please install ${MIN_ANGULAR_CLI_VERSION} or higher`);

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.start = void 0;
const utils_1 = require("../utils");
const util_1 = require("@stryker-mutator/util");
async function start() {
// Make sure require karma from inside this function, that way it won't break if karma isn't installed and this file is required.
const karma = utils_1.requireModule('karma');
const karma = util_1.requireResolve('karma');
await new karma.Server({

@@ -9,0 +9,0 @@ configFile: require.resolve('./stryker-karma.conf'),

@@ -6,3 +6,2 @@ "use strict";

const test_hooks_middleware_1 = require("../karma-plugins/test-hooks-middleware");
const utils_1 = require("../utils");
function setDefaultOptions(config) {

@@ -19,3 +18,6 @@ config.set({

try {
const userConfig = utils_1.requireModule(configFileName);
const userConfig = util_1.requireResolve(configFileName);
if (typeof userConfig !== 'function') {
throw new TypeError(`Karma config file "${configFileName}" should export a function! Found: ${typeof userConfig}`);
}
userConfig(config);

@@ -22,0 +24,0 @@ config.configFile = configFileName; // override config to ensure karma is as user-like as possible

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc