-
Notifications
You must be signed in to change notification settings - Fork 306
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(config): add
setup-jest.mjs
for ESM mode (#1463)
- Loading branch information
Showing
26 changed files
with
91 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,20 @@ | ||
import ngPreset from 'jest-preset-angular/presets/index.js'; | ||
|
||
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ | ||
const jestConfig = { | ||
...ngPreset.defaultsESM, | ||
displayName: 'app1', | ||
preset: 'jest-preset-angular/presets/defaults-esm', | ||
globals: { | ||
'ts-jest': { | ||
useESM: true, | ||
stringifyContentPathRegex: '\\.(html|svg)$', | ||
...ngPreset.defaultsESM.globals["ts-jest"], | ||
tsconfig: '<rootDir>/tsconfig-esm.spec.json', | ||
}, | ||
}, | ||
moduleNameMapper: { | ||
tslib: 'tslib/tslib.es6.js', | ||
rxjs: '<rootDir>/../../node_modules/rxjs/dist/bundles/rxjs.umd.js', | ||
}, | ||
setupFilesAfterEnv: ['<rootDir>/setup-jest.ts'], | ||
setupFilesAfterEnv: ['<rootDir>/setup-jest-esm.ts'], | ||
} | ||
|
||
export default jestConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import 'jest-preset-angular/setup-jest.mjs'; | ||
import './jest-global-mocks'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,2 @@ | ||
// Can't use standard setup-jest, b/c it uses require() | ||
// import 'jest-preset-angular/setup-jest'; | ||
|
||
import 'zone.js/fesm2015/zone-testing-bundle.min.js'; | ||
import 'jest-preset-angular/setup-jest'; | ||
import './jest-global-mocks'; | ||
|
||
import { getTestBed } from '@angular/core/testing'; | ||
import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing'; | ||
|
||
getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,20 @@ | ||
import ngPreset from 'jest-preset-angular/presets/index.js'; | ||
|
||
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */ | ||
const jestConfig = { | ||
...ngPreset.defaultsESM, | ||
displayName: 'user-lib', | ||
preset: 'jest-preset-angular/presets/defaults-esm', | ||
globals: { | ||
'ts-jest': { | ||
useESM: true, | ||
stringifyContentPathRegex: '\\.(html|svg)$', | ||
...ngPreset.defaultsESM.globals["ts-jest"], | ||
tsconfig: '<rootDir>/tsconfig-esm.spec.json', | ||
}, | ||
}, | ||
moduleNameMapper: { | ||
tslib: 'tslib/tslib.es6.js', | ||
rxjs: '<rootDir>/../../node_modules/rxjs/dist/bundles/rxjs.umd.js', | ||
}, | ||
setupFilesAfterEnv: ['<rootDir>/setup-jest.ts'], | ||
setupFilesAfterEnv: ['<rootDir>/setup-jest-esm.ts'], | ||
} | ||
|
||
export default jestConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import 'jest-preset-angular/setup-jest.mjs'; | ||
import './jest-global-mocks'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,2 @@ | ||
// Can't use standard setup-jest, b/c it uses require() | ||
// import 'jest-preset-angular/setup-jest'; | ||
|
||
import 'zone.js/fesm2015/zone-testing-bundle.min.js'; | ||
import 'jest-preset-angular/setup-jest'; | ||
import './jest-global-mocks'; | ||
|
||
import { getTestBed } from '@angular/core/testing'; | ||
import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing'; | ||
|
||
getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import 'jest-preset-angular/setup-jest.mjs'; | ||
import './jest-global-mocks'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import 'jest-preset-angular/setup-jest.mjs'; | ||
import './jest-global-mocks'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import 'jest-preset-angular/setup-jest.mjs'; | ||
import './jest-global-mocks'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,2 @@ | ||
// Can't use standard setup-jest, b/c it uses require() | ||
// import 'jest-preset-angular/setup-jest'; | ||
|
||
import 'zone.js/fesm2015/zone-testing-bundle.min.js'; | ||
import 'jest-preset-angular/setup-jest'; | ||
import './jest-global-mocks'; | ||
|
||
import { getTestBed } from '@angular/core/testing'; | ||
import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing'; | ||
|
||
getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
examples/example-app-yarn-workspace/packages/angular-app/setup-jest-esm.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import 'jest-preset-angular/setup-jest.mjs'; | ||
import './jest-global-mocks'; |
10 changes: 1 addition & 9 deletions
10
examples/example-app-yarn-workspace/packages/angular-app/setup-jest.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,2 @@ | ||
// Can't use standard setup-jest, b/c it uses require() | ||
// import 'jest-preset-angular/setup-jest'; | ||
|
||
import 'zone.js/fesm2015/zone-testing-bundle.min.js'; | ||
import 'jest-preset-angular/setup-jest'; | ||
import './jest-global-mocks'; | ||
|
||
import { getTestBed } from '@angular/core/testing'; | ||
import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing'; | ||
|
||
getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
examples/example-app-yarn-workspace/packages/user/setup-jest-esm.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import 'jest-preset-angular/setup-jest.mjs'; | ||
import './jest-global-mocks'; |
10 changes: 1 addition & 9 deletions
10
examples/example-app-yarn-workspace/packages/user/setup-jest.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,2 @@ | ||
// Can't use standard setup-jest, b/c it uses require() | ||
// import 'jest-preset-angular/setup-jest'; | ||
|
||
import 'zone.js/fesm2015/zone-testing-bundle.min.js'; | ||
import 'jest-preset-angular/setup-jest'; | ||
import './jest-global-mocks'; | ||
|
||
import { getTestBed } from '@angular/core/testing'; | ||
import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing'; | ||
|
||
getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,9 @@ | ||
module.exports = require('./build/config/setup-jest'); | ||
require('zone.js/bundles/zone-testing-bundle.umd'); | ||
|
||
const { getTestBed } = require('@angular/core/testing'); | ||
const { | ||
BrowserDynamicTestingModule, | ||
platformBrowserDynamicTesting, | ||
} = require('@angular/platform-browser-dynamic/testing'); | ||
|
||
getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters