Skip to content

Commit

Permalink
fix(jest): set path to tsconfig correctly (#1443)
Browse files Browse the repository at this point in the history
* fix(jest): set path to tsconfig correctly

Resolves: #1408

* fix(jest): fix undefined defaultTransformerOptions

* chore(): remove obsolete tsconfig.spec.json

---------

Co-authored-by: JeB <[email protected]>
  • Loading branch information
pixtron and just-jeb authored Aug 23, 2023
1 parent ebdd618 commit 2918f2b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
7 changes: 0 additions & 7 deletions examples/jest/multiple-apps/tsconfig.spec.json

This file was deleted.

6 changes: 4 additions & 2 deletions packages/jest/src/default-config.resolver.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ describe('Resolve project default configuration', () => {
it('Should resolve tsconfig relatively to project root', () => {
const config = defaultConfigResolver.resolveForProject(normalize('/some/cool/directory'));
expect(config.transform[defaultConfigResolver.tsJestTransformRegExp]).toEqual([
'ts-jest',
'jest-preset-angular',
{
stringifyContentPathRegex: '\\.(html|svg)$',
tsconfig: getSystemPath(normalize(`/some/cool/directory/${tsConfigName}`)),
},
]);
Expand All @@ -23,8 +24,9 @@ describe('Resolve project default configuration', () => {
});
const config = defaultConfigResolver.resolveForProject(normalize('/some/cool/project'));
expect(config.transform[defaultConfigResolver.tsJestTransformRegExp]).toEqual([
'ts-jest',
'jest-preset-angular',
{
stringifyContentPathRegex: '\\.(html|svg)$',
tsconfig: getSystemPath(normalize(`/some/cool/project/ts-configs/tsconfig.spec.json`)),
},
]);
Expand Down
6 changes: 4 additions & 2 deletions packages/jest/src/default-config.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const getMockFiles = (enabledMocks: string[] = []): string[] =>

export class DefaultConfigResolver {
// Exposed publicly for testing purposes.
readonly tsJestTransformRegExp = '^.+\\.tsx?$';
readonly tsJestTransformRegExp = '^.+\\.(ts|js|mjs|html|svg)$';

constructor(private options: JestBuilderSchema) {}

Expand All @@ -39,8 +39,10 @@ export class DefaultConfigResolver {
testMatch: [`${getSystemPath(projectRoot)}${testPattern}`],
transform: {
[this.tsJestTransformRegExp]: [
'ts-jest',
'jest-preset-angular',
{
// see: jest-preset-angular defaultTransformerOptions https://github.com/thymikee/jest-preset-angular/blob/main/src/presets/index.ts#L11
stringifyContentPathRegex: '\\.(html|svg)$',
// Join with the default `tsConfigName` if the `tsConfig` option is not provided
tsconfig: getTsConfigPath(projectRoot, this.options),
},
Expand Down

0 comments on commit 2918f2b

Please sign in to comment.