feat(testing): add type annotation for Jest configuration export (#30059)
This commit is contained in:
parent
d8345147ed
commit
af930c396d
@ -1,5 +1,6 @@
|
||||
import type { Config } from 'jest';
|
||||
import { getJestProjectsAsync } from '@nx/jest';
|
||||
|
||||
export default async () => ({
|
||||
export default async (): Promise<Config> => ({
|
||||
projects: await getJestProjectsAsync(),
|
||||
});
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`createJestConfig should generate files 1`] = `
|
||||
"import { getJestProjectsAsync } from '@nx/jest';
|
||||
"import type { Config } from 'jest';
|
||||
import { getJestProjectsAsync } from '@nx/jest';
|
||||
|
||||
export default async () => ({
|
||||
export default async (): Promise<Config> => ({
|
||||
projects: await getJestProjectsAsync()
|
||||
});"
|
||||
`;
|
||||
|
||||
@ -153,9 +153,10 @@ export default {
|
||||
"
|
||||
`);
|
||||
expect(tree.read('jest.config.ts', 'utf-8'))
|
||||
.toEqual(`import { getJestProjectsAsync } from '@nx/jest';
|
||||
.toEqual(`import type { Config } from 'jest';
|
||||
import { getJestProjectsAsync } from '@nx/jest';
|
||||
|
||||
export default async () => ({
|
||||
export default async (): Promise<Config> => ({
|
||||
projects: await getJestProjectsAsync()
|
||||
});`);
|
||||
expect(readProjectConfiguration(tree, 'my-project').targets.test)
|
||||
|
||||
@ -151,9 +151,10 @@ function generateGlobalConfig(tree: Tree, isJS: boolean) {
|
||||
module.exports = async () => ({
|
||||
projects: await getJestProjectsAsync()
|
||||
});`
|
||||
: `import { getJestProjectsAsync } from '@nx/jest';
|
||||
: `import type { Config } from 'jest';
|
||||
import { getJestProjectsAsync } from '@nx/jest';
|
||||
|
||||
export default async () => ({
|
||||
export default async (): Promise<Config> => ({
|
||||
projects: await getJestProjectsAsync()
|
||||
});`;
|
||||
tree.write(`jest.config.${isJS ? 'js' : 'ts'}`, contents);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user