Skip to content

Commit

Permalink
feat(config): remove hardcoded logic setting target to ES2015
Browse files Browse the repository at this point in the history
  • Loading branch information
anh.pham committed Sep 25, 2022
1 parent da0ad0a commit 8458ab8
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 24 deletions.
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

0 comments on commit 8458ab8

Please sign in to comment.