-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(angular): use new test environment function from `jest-preset-an…
…gular`
- Loading branch information
1 parent
9ad6b8c
commit ed9bca1
Showing
4 changed files
with
67 additions
and
10 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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import type { Tree } from '@nx/devkit'; | ||
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing'; | ||
import { UnitTestRunner } from '../../utils/test-runners'; | ||
import { addJest } from './add-jest'; | ||
import { generateTestApplication } from './testing'; | ||
|
||
describe('addJest', () => { | ||
let tree: Tree; | ||
|
||
beforeEach(async () => { | ||
tree = createTreeWithEmptyWorkspace(); | ||
await generateTestApplication(tree, { | ||
name: 'app1', | ||
directory: 'app1', | ||
unitTestRunner: UnitTestRunner.None, | ||
skipFormat: true, | ||
}); | ||
}); | ||
|
||
it('generate the test setup file', async () => { | ||
await addJest(tree, { | ||
name: 'app1', | ||
projectRoot: 'app1', | ||
skipPackageJson: false, | ||
strict: false, | ||
}); | ||
|
||
expect(tree.read('app1/src/test-setup.ts', 'utf-8')).toMatchInlineSnapshot(` | ||
"import { setupZoneTestEnv } from 'jest-preset-angular/setup-env/zone'; | ||
setupZoneTestEnv(); | ||
" | ||
`); | ||
}); | ||
|
||
it('generate the test setup file with strict', async () => { | ||
await addJest(tree, { | ||
name: 'app1', | ||
projectRoot: 'app1', | ||
skipPackageJson: false, | ||
strict: true, | ||
}); | ||
|
||
expect(tree.read('app1/src/test-setup.ts', 'utf-8')).toMatchInlineSnapshot(` | ||
"import { setupZoneTestEnv } from 'jest-preset-angular/setup-env/zone'; | ||
setupZoneTestEnv({ | ||
errorOnUnknownElements: true, | ||
errorOnUnknownProperties: true | ||
}); | ||
" | ||
`); | ||
}); | ||
}); |
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
4 changes: 3 additions & 1 deletion
4
packages/jest/src/generators/configuration/files-angular/src/test-setup.ts__tmpl__
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,3 @@ | ||
import 'jest-preset-angular/setup-jest'; | ||
import { setupZoneTestEnv } from 'jest-preset-angular/setup-env/zone'; | ||
|
||
setupZoneTestEnv(); |