Skip to content

Commit

Permalink
fix(ignore patterns): always ignore *.tsbuildinfo files (#2985)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicojs committed Jul 2, 2021
1 parent 6b4c3e1 commit 794f103
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/configuration.md
Expand Up @@ -138,7 +138,7 @@ Config file: `"ignorePatterns": ["dist", "coverage"]`<br />

Specify the patterns to all files or directories that are not used to run your tests and thus should _not be copied_ to the sandbox directory for mutation testing. Each patterns in this array should be a [`.gitignore`-style glob pattern](https://git-scm.com/docs/gitignore#_pattern_format).

These patterns are **always ignored**: `['node_modules', '.git', '/reports', '/stryker.log', '.stryker-tmp']`. Because Stryker always ignores these, you should rarely have to adjust the `"ignorePatterns"` setting at all. If you want to undo one of these ignore patterns, you can use the `!` prefix, for example: `['!node_modules']`.
These patterns are **always ignored**: `['node_modules', '.git', '/reports' '*.tsbuildinfo', '/stryker.log', '.stryker-tmp']`. Because Stryker always ignores these, you should rarely have to adjust the `"ignorePatterns"` setting at all. If you want to undo one of these ignore patterns, you can use the `!` prefix, for example: `['!node_modules']`.

If a glob pattern starts with `/`, the pattern is relative to the current working directory. For example, `/foo.js` matches to `foo.js` but not `subdir/foo.js`.

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/input/input-file-resolver.ts
Expand Up @@ -28,7 +28,7 @@ function toReportSourceFile(file: File): SourceFile {
};
}

const ALWAYS_IGNORE = Object.freeze(['node_modules', '.git', '/reports', '/stryker.log']);
const ALWAYS_IGNORE = Object.freeze(['node_modules', '.git', '/reports', '*.tsbuildinfo', '/stryker.log']);

export const IGNORE_PATTERN_CHARACTER = '!';
export const MUTATION_RANGE_REGEX = /(.*?):((\d+)(?::(\d+))?-(\d+)(?::(\d+))?)$/;
Expand Down
8 changes: 6 additions & 2 deletions packages/core/test/unit/input/input-file-resolver.spec.ts
Expand Up @@ -29,7 +29,7 @@ describe(InputFileResolver.name, () => {
const sut = createSut();
await sut.resolve();
expect(testInjector.logger.warn).calledWith(
`No files found in directory ${process.cwd()} using ignore rules: ["node_modules",".git","/reports","/stryker.log",".stryker-tmp"]. Make sure you run Stryker from the root directory of your project with the correct "ignorePatterns".`
`No files found in directory ${process.cwd()} using ignore rules: ["node_modules",".git","/reports","*.tsbuildinfo","/stryker.log",".stryker-tmp"]. Make sure you run Stryker from the root directory of your project with the correct "ignorePatterns".`
);
});

Expand Down Expand Up @@ -90,14 +90,18 @@ describe(InputFileResolver.name, () => {
expect(files[0].name).eq(path.resolve('packages', 'app', 'src', 'index.js'));
});

it('should ignore node_modules, .git, reports, stryker.log and .stryker-tmp by default', async () => {
it('should ignore node_modules, .git, reports, stryker.log, *.tsbuildinfo and .stryker-tmp by default', async () => {
// Arrange
stubFileSystem({
'.git': { config: '' },
node_modules: { rimraf: { 'index.js': '' } },
'.stryker-tmp': { 'stryker-sandbox-123': { src: { 'index.js': '' } } },
'index.js': '',
'stryker.log': '',
'tsconfig.src.tsbuildinfo': '',
dist: {
'tsconfig.tsbuildinfo': '',
},
reports: { mutation: { 'mutation.json': '' } },
});
const sut = createSut();
Expand Down

0 comments on commit 794f103

Please sign in to comment.