Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(config): remove hardcoded logic setting target to ES2015 #1788

Merged
merged 1 commit into from
Sep 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ Adjust your `tsconfig.spec.json` to be:
}
```

**IMPORTANT**

Angular doesn't support native `async/await` in testing with `target` higher than `ES2016`, see https://github.com/angular/components/issues/21632#issuecomment-764975917

## Migration from Angular < 13

Check out our [Migration from Angular < 13 guidance](https://thymikee.github.io/jest-preset-angular/docs/guides/angular-13+)
Expand Down
5 changes: 2 additions & 3 deletions e2e/async/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ module.exports = {
globals: {
'ts-jest': {
tsconfig: {
/**
* Set at ES2018 to test Angular doesn't work with ES2017+
/** Angular doesn't work with ES2017+
* see https://github.com/angular/components/issues/21632#issuecomment-764975917
*/
target: 'ES2018',
target: 'ES2016',
},
},
},
Expand Down
15 changes: 0 additions & 15 deletions src/config/ng-jest-config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,4 @@ describe('NgJestConfig', () => {
expect(compilerOptions.allowJs).toBe(true);
expect(compilerOptions.target).toBe(ScriptTarget.ES2015);
});

test('should set typescript target to ES2015 if user is using target higher than ES2016', () => {
expect(
new NgJestConfig({
globals: {
'ts-jest': {
tsconfig: {
target: 'ES2017',
},
},
},
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any).parsedTsConfig.options.target,
).toBe(ScriptTarget.ES2015);
});
});
6 changes: 0 additions & 6 deletions src/config/ng-jest-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,6 @@ export class NgJestConfig extends ConfigSet {
result.options.enableResourceInlining = false;
// Since we define preset default also transform `js` so we need to set `allowJs` true
result.options.allowJs = true;
const ts = this.compilerModule;
const scriptTarget = result.options.target ?? ts.ScriptTarget?.ES2015;
if (scriptTarget > ts.ScriptTarget?.ES2016) {
// See https://github.com/angular/components/issues/21632#issuecomment-764975917
result.options.target = ts.ScriptTarget?.ES2015;
}

return result;
}
Expand Down
6 changes: 6 additions & 0 deletions website/docs/getting-started/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ Adjust your `tsconfig.spec.json` to be:
}
```

:::important

Angular doesn't support native `async/await` in testing with `target` higher than `ES2016`, see https://github.com/angular/components/issues/21632#issuecomment-764975917

:::

### Customizing

#### Global mocks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ Adjust your `tsconfig.spec.json` to be:
}
```

:::important

Angular doesn't support native `async/await` in testing with `target` higher than `ES2016`, see https://github.com/angular/components/issues/21632#issuecomment-764975917

:::

### Customizing

#### Global mocks
Expand Down