Skip to content

Commit

Permalink
feat(mutate): a new default for mutate (#2452)
Browse files Browse the repository at this point in the history
Change the default patterns for which files should be mutated to:

```json
{ 
  "mutate": [
    "{src,lib}/**/!(*.+(s|S)pec|*.+(t|T)est).+(cjs|mjs|js|ts|jsx|tsx|html|vue)", 
    "!{src,lib}/**/__tests__/**/*.+(cjs|mjs|js|ts|jsx|tsx|html|vue)"
  ]
}
```

Basically means any JS or friend file in the `lib` or `src` directory that isn't obviously a test file.

Fixes #2384
  • Loading branch information
nicojs committed Sep 3, 2020
1 parent c9efa78 commit 673516d
Show file tree
Hide file tree
Showing 29 changed files with 49 additions and 31 deletions.
3 changes: 0 additions & 3 deletions e2e/test/jasmine-ts-node/stryker.conf.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"$schema": "../../node_modules/@stryker-mutator/core/schema/stryker-schema.json",
"mutate": [
"{src,lib}/**/*.ts?(x)"
],
"checkers": [
"typescript"
],
Expand Down
4 changes: 0 additions & 4 deletions e2e/test/jest-react-enyme-ts/stryker.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
"packageManager": "npm",
"testRunner": "jest",
"tempDirName": "stryker-tmp",
"mutate": [
"src/*.tsx",
"!src/*.spec.tsx"
],
"concurrency": 2,
"coverageAnalysis": "off",
"reporters": [
Expand Down
3 changes: 0 additions & 3 deletions e2e/test/mocha-ts-node/stryker.conf.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"$schema": "../../node_modules/@stryker-mutator/core/schema/stryker-schema.json",
"mutate": [
"{src,lib}/**/*.ts?(x)"
],
"packageManager": "npm",
"testRunner": "mocha",
"concurrency": 1,
Expand Down
3 changes: 0 additions & 3 deletions e2e/test/typescript-transpiling/stryker.conf.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"$schema": "../../node_modules/@stryker-mutator/core/schema/stryker-schema.json",
"mutate": [
"src/*.ts"
],
"packageManager": "npm",
"testRunner": "mocha",
"concurrency": 1,
Expand Down
4 changes: 0 additions & 4 deletions e2e/test/vue-cli-javascript-jest/stryker.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
"mutator": {
"plugins": []
},
"mutate": [
"{src,lib}/**/*.+(js|vue)",
"!{src,lib}/**/*.spec.js"
],
"tempDirName": "stryker-tmp",
"packageManager": "npm",
"testRunner": "jest",
Expand Down
4 changes: 0 additions & 4 deletions e2e/test/vue-cli-typescript-mocha/stryker.conf.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
{
"$schema": "../../node_modules/@stryker-mutator/core/schema/stryker-schema.json",
"mutate": [
"{src,lib}/**/*.+(ts|vue)",
"!{src,lib}/**/*.spec.ts"
],
"packageManager": "npm",
"testRunner": "mocha",
"concurrency": 2,
Expand Down
3 changes: 0 additions & 3 deletions e2e/test/vue-javascript/stryker.conf.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"$schema": "../../node_modules/@stryker-mutator/core/schema/stryker-schema.json",
"mutate": [
"src/**/*.js", "src/**/*.vue"
],
"testRunner": "karma",
"reporters": [
"clear-text",
Expand Down
6 changes: 2 additions & 4 deletions packages/api/schema/stryker-core.json
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,8 @@
"type": "string"
},
"default": [
"{src,lib}/**/*.js?(x)",
"!{src,lib}/**/__tests__/**/*.js?(x)",
"!{src,lib}/**/?(*.)+(spec|test).js?(x)",
"!{src,lib}/**/*+(Spec|Test).js?(x)"
"{src,lib}/**/!(*.+(s|S)pec|*.+(t|T)est).+(cjs|mjs|js|ts|jsx|tsx|html|vue)",
"!{src,lib}/**/__tests__/**/*.+(cjs|mjs|js|ts|jsx|tsx|html|vue)"
]
},
"mutator": {
Expand Down
3 changes: 0 additions & 3 deletions packages/core/test/helpers/setupMocha.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ chai.use(sinonChai);
chai.use(chaiAsPromised);

export const mochaHooks = {
before() {
console.log('BEFORE ALL!');
},
afterEach() {
sinon.restore();
testInjector.reset();
Expand Down
47 changes: 47 additions & 0 deletions packages/core/test/integration/input/InputFileResolver.it.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import path = require('path');

import { factory, testInjector } from '@stryker-mutator/test-helpers';
import { expect } from 'chai';

import { coreTokens } from '../../../src/di';
import InputFileResolver from '../../../src/input/InputFileResolver';

const resolveTestResource: typeof path.resolve = path.resolve.bind(
path,
__dirname,
'..' /* input */,
'..' /* integration */,
'..' /* test */,
'testResources',
'input-files'
);

describe(`${InputFileResolver.name} integration`, () => {
let sut: InputFileResolver;
let originalCwd: string;

beforeEach(() => {
originalCwd = process.cwd();
sut = testInjector.injector.provideValue(coreTokens.reporter, factory.reporter()).injectClass(InputFileResolver);
});

afterEach(() => {
process.chdir(originalCwd);
});

it('should by default resolve reasonable project source files to be mutated', async () => {
process.chdir(resolveTestResource());
const inputFiles = await sut.resolve();
expect(inputFiles.filesToMutate.map((file) => file.name)).deep.eq([
resolveTestResource('lib', 'string-utils.js'),
resolveTestResource('src', 'app.ts'),
resolveTestResource('src', 'components', 'calculator', 'calculator.component.tsx'),
resolveTestResource('src', 'components', 'heading', 'heading.component.vue'),
resolveTestResource('src', 'index.html'),
resolveTestResource('src', 'services', 'storage.ts'),
resolveTestResource('src', 'services', 'test.ts'),
resolveTestResource('src', 'utils', 'commonjs.cjs'),
resolveTestResource('src', 'utils', 'esm.mjs'),
]);
});
});
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.

0 comments on commit 673516d

Please sign in to comment.