feat(testing): rename jest-project generator to "configuration" generator for consistency in naming (#18006)

This commit is contained in:
Jack Hsu 2023-07-07 16:17:41 -04:00 committed by GitHub
parent 5a7ffb93c9
commit 38fa586b78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
38 changed files with 176 additions and 78 deletions

View File

@ -5174,9 +5174,9 @@
"disableCollapsible": false "disableCollapsible": false
}, },
{ {
"id": "jest-project", "id": "configuration",
"path": "/packages/jest/generators/jest-project", "path": "/packages/jest/generators/configuration",
"name": "jest-project", "name": "configuration",
"children": [], "children": [],
"isExternal": false, "isExternal": false,
"disableCollapsible": false "disableCollapsible": false

View File

@ -963,13 +963,13 @@
"path": "/packages/jest/generators/init", "path": "/packages/jest/generators/init",
"type": "generator" "type": "generator"
}, },
"/packages/jest/generators/jest-project": { "/packages/jest/generators/configuration": {
"description": "Add Jest configuration to a project.", "description": "Add Jest configuration to a project.",
"file": "generated/packages/jest/generators/jest-project.json", "file": "generated/packages/jest/generators/configuration.json",
"hidden": true, "hidden": true,
"name": "jest-project", "name": "configuration",
"originalFilePath": "/packages/jest/src/generators/jest-project/schema.json", "originalFilePath": "/packages/jest/src/generators/configuration/schema.json",
"path": "/packages/jest/generators/jest-project", "path": "/packages/jest/generators/configuration",
"type": "generator" "type": "generator"
} }
}, },

View File

@ -950,11 +950,11 @@
}, },
{ {
"description": "Add Jest configuration to a project.", "description": "Add Jest configuration to a project.",
"file": "generated/packages/jest/generators/jest-project.json", "file": "generated/packages/jest/generators/configuration.json",
"hidden": true, "hidden": true,
"name": "jest-project", "name": "configuration",
"originalFilePath": "/packages/jest/src/generators/jest-project/schema.json", "originalFilePath": "/packages/jest/src/generators/configuration/schema.json",
"path": "jest/generators/jest-project", "path": "jest/generators/configuration",
"type": "generator" "type": "generator"
} }
], ],

View File

@ -0,0 +1,89 @@
{
"name": "configuration",
"factory": "./src/generators/configuration/configuration",
"schema": {
"$schema": "http://json-schema.org/schema",
"$id": "NxJestProject",
"cli": "nx",
"title": "Add Jest Configuration to a project",
"description": "Add Jest Configuration to a project.",
"type": "object",
"properties": {
"project": {
"type": "string",
"description": "The name of the project.",
"$default": { "$source": "projectName" },
"x-priority": "important"
},
"skipSetupFile": {
"type": "boolean",
"description": "Skips the setup file required for angular.",
"default": false,
"x-deprecated": "Use `--setup-file` instead."
},
"setupFile": {
"type": "string",
"enum": ["none", "angular", "web-components"],
"description": "The setup file to be generated.",
"default": "none",
"x-priority": "important"
},
"skipSerializers": {
"type": "boolean",
"description": "Skips the serializers required to snapshot angular templates.",
"default": false
},
"supportTsx": {
"type": "boolean",
"description": "Setup `tsx` support.",
"default": false,
"x-priority": "important"
},
"testEnvironment": {
"type": "string",
"enum": ["jsdom", "node", "none"],
"description": "The test environment for jest.",
"default": "jsdom",
"x-priority": "important"
},
"compiler": {
"type": "string",
"enum": ["tsc", "babel", "swc"],
"description": "The compiler to use for source and tests.",
"default": "tsc"
},
"babelJest": {
"type": "boolean",
"alias": "babel-jest",
"description": "Use `babel-jest` instead of `ts-jest`.",
"x-deprecated": "Use `--compiler=babel` instead.",
"default": false
},
"skipFormat": {
"description": "Skip formatting files",
"type": "boolean",
"default": false,
"x-priority": "internal"
},
"skipPackageJson": {
"type": "boolean",
"default": false,
"description": "Do not add dependencies to `package.json`.",
"x-priority": "internal"
},
"js": {
"type": "boolean",
"default": false,
"description": "Use JavaScript instead of TypeScript for config files"
}
},
"required": [],
"presets": []
},
"description": "Add Jest configuration to a project.",
"hidden": true,
"implementation": "/packages/jest/src/generators/configuration/configuration.ts",
"aliases": [],
"path": "/packages/jest/src/generators/configuration/schema.json",
"type": "generator"
}

View File

@ -393,7 +393,7 @@
- [jest](/packages/jest/executors/jest) - [jest](/packages/jest/executors/jest)
- [generators](/packages/jest/generators) - [generators](/packages/jest/generators)
- [init](/packages/jest/generators/init) - [init](/packages/jest/generators/init)
- [jest-project](/packages/jest/generators/jest-project) - [configuration](/packages/jest/generators/configuration)
- [js](/packages/js) - [js](/packages/js)
- [documents](/packages/js/documents) - [documents](/packages/js/documents)
- [Overview](/packages/js/documents/overview) - [Overview](/packages/js/documents/overview)

View File

@ -164,8 +164,8 @@ describe('nx-dev: Packages Section', () => {
{ title: '@nx/jest', path: '/packages/jest' }, { title: '@nx/jest', path: '/packages/jest' },
{ title: '@nx/jest:init', path: '/packages/jest/generators/init' }, { title: '@nx/jest:init', path: '/packages/jest/generators/init' },
{ {
title: '@nx/jest:jest-project', title: '@nx/jest:configuration',
path: '/packages/jest/generators/jest-project', path: '/packages/jest/generators/configuration',
}, },
{ title: '@nx/jest', path: '/packages/jest/executors/jest' }, { title: '@nx/jest', path: '/packages/jest/executors/jest' },
{ title: '@nx/js', path: '/packages/js' }, { title: '@nx/js', path: '/packages/js' },

View File

@ -150,6 +150,8 @@ const schemaUrls = {
'/packages/cypress/generators/component-configuration', '/packages/cypress/generators/component-configuration',
'/packages/esbuild/generators/esbuild-project': '/packages/esbuild/generators/esbuild-project':
'/packages/esbuild/generators/configuration', '/packages/esbuild/generators/configuration',
'/packages/jest/generators/jest-project':
'/packages/jest/generators/configuration',
'/packages/nx-plugin/generators/executor': '/packages/nx-plugin/generators/executor':
'/packages/plugin/generators/executor', '/packages/plugin/generators/executor',
'/packages/nx-plugin/generators/migration': '/packages/nx-plugin/generators/migration':

View File

@ -1,13 +1,13 @@
import { Tree, joinPathFragments } from '@nx/devkit'; import { Tree, joinPathFragments } from '@nx/devkit';
import type { NormalizedSchema } from './normalized-schema'; import type { NormalizedSchema } from './normalized-schema';
import { jestProjectGenerator } from '@nx/jest'; import { configurationGenerator } from '@nx/jest';
import { UnitTestRunner } from '../../../utils/test-runners'; import { UnitTestRunner } from '../../../utils/test-runners';
export async function addUnitTestRunner(host: Tree, options: NormalizedSchema) { export async function addUnitTestRunner(host: Tree, options: NormalizedSchema) {
if (options.unitTestRunner === UnitTestRunner.Jest) { if (options.unitTestRunner === UnitTestRunner.Jest) {
await jestProjectGenerator(host, { await configurationGenerator(host, {
project: options.name, project: options.name,
setupFile: 'angular', setupFile: 'angular',
supportTsx: false, supportTsx: false,

View File

@ -5,7 +5,7 @@ import {
joinPathFragments, joinPathFragments,
Tree, Tree,
} from '@nx/devkit'; } from '@nx/devkit';
import { jestProjectGenerator } from '@nx/jest'; import { configurationGenerator } from '@nx/jest';
import { Linter } from '@nx/linter'; import { Linter } from '@nx/linter';
import { addTsConfigPath } from '@nx/js'; import { addTsConfigPath } from '@nx/js';
import { lt } from 'semver'; import { lt } from 'semver';
@ -124,7 +124,7 @@ async function addUnitTestRunner(
options: NormalizedSchema['libraryOptions'] options: NormalizedSchema['libraryOptions']
) { ) {
if (options.unitTestRunner === 'jest') { if (options.unitTestRunner === 'jest') {
await jestProjectGenerator(host, { await configurationGenerator(host, {
project: options.name, project: options.name,
setupFile: 'angular', setupFile: 'angular',
supportTsx: false, supportTsx: false,

View File

@ -1,5 +1,5 @@
import { Tree } from '@nx/devkit'; import { Tree } from '@nx/devkit';
import { jestProjectGenerator } from '@nx/jest'; import { configurationGenerator } from '@nx/jest';
export async function addJest( export async function addJest(
host: Tree, host: Tree,
@ -13,7 +13,7 @@ export async function addJest(
return () => {}; return () => {};
} }
const jestTask = await jestProjectGenerator(host, { const jestTask = await configurationGenerator(host, {
js, js,
project: projectName, project: projectName,
supportTsx: true, supportTsx: true,

View File

@ -9,9 +9,9 @@
"aliases": ["ng-add"], "aliases": ["ng-add"],
"hidden": true "hidden": true
}, },
"jest-project": { "configuration": {
"factory": "./src/generators/jest-project/jest-project#jestProjectSchematic", "factory": "./src/generators/configuration/configuration#compat",
"schema": "./src/generators/jest-project/schema.json", "schema": "./src/generators/configuration/schema.json",
"description": "Add Jest configuration to a project.", "description": "Add Jest configuration to a project.",
"hidden": true "hidden": true
} }
@ -24,9 +24,9 @@
"aliases": ["ng-add"], "aliases": ["ng-add"],
"hidden": true "hidden": true
}, },
"jest-project": { "configuration": {
"factory": "./src/generators/jest-project/jest-project#jestProjectGenerator", "factory": "./src/generators/configuration/configuration",
"schema": "./src/generators/jest-project/schema.json", "schema": "./src/generators/configuration/schema.json",
"description": "Add Jest configuration to a project.", "description": "Add Jest configuration to a project.",
"hidden": true "hidden": true
} }

View File

@ -1,9 +1,15 @@
import { configurationGenerator } from './src/generators/configuration/configuration';
export { configurationGenerator };
// Exported for backwards compatibility in case a plugin is using the old name.
/** @deprecated Use `configurationGenerator` instead. */
export const jestProjectGenerator = configurationGenerator;
export { export {
addPropertyToJestConfig, addPropertyToJestConfig,
removePropertyFromJestConfig, removePropertyFromJestConfig,
} from './src/utils/config/update-config'; } from './src/utils/config/update-config';
export { jestConfigObjectAst } from './src/utils/config/functions'; export { jestConfigObjectAst } from './src/utils/config/functions';
export { jestProjectGenerator } from './src/generators/jest-project/jest-project';
export { jestInitGenerator } from './src/generators/init/init'; export { jestInitGenerator } from './src/generators/init/init';
export { export {
getJestProjects, getJestProjects,

View File

@ -8,7 +8,7 @@ import {
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing'; import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
import { jestConfigObject } from '../../utils/config/functions'; import { jestConfigObject } from '../../utils/config/functions';
import { jestProjectGenerator } from './jest-project'; import configurationGenerator from './configuration';
import { JestProjectSchema } from './schema.d'; import { JestProjectSchema } from './schema.d';
describe('jestProject', () => { describe('jestProject', () => {
@ -45,7 +45,7 @@ describe('jestProject', () => {
}); });
it('should generate files', async () => { it('should generate files', async () => {
await jestProjectGenerator(tree, { await configurationGenerator(tree, {
...defaultOptions, ...defaultOptions,
project: 'lib1', project: 'lib1',
setupFile: 'angular', setupFile: 'angular',
@ -61,7 +61,7 @@ describe('jestProject', () => {
}); });
it('should alter project configuration', async () => { it('should alter project configuration', async () => {
await jestProjectGenerator(tree, { await configurationGenerator(tree, {
...defaultOptions, ...defaultOptions,
project: 'lib1', project: 'lib1',
setupFile: 'angular', setupFile: 'angular',
@ -87,7 +87,7 @@ describe('jestProject', () => {
}); });
it('should create a jest.config.ts', async () => { it('should create a jest.config.ts', async () => {
await jestProjectGenerator(tree, { await configurationGenerator(tree, {
...defaultOptions, ...defaultOptions,
project: 'lib1', project: 'lib1',
} as JestProjectSchema); } as JestProjectSchema);
@ -95,7 +95,7 @@ describe('jestProject', () => {
}); });
it('should add a reference to solution tsconfig.json', async () => { it('should add a reference to solution tsconfig.json', async () => {
await jestProjectGenerator(tree, { await configurationGenerator(tree, {
...defaultOptions, ...defaultOptions,
project: 'lib1', project: 'lib1',
} as JestProjectSchema); } as JestProjectSchema);
@ -106,7 +106,7 @@ describe('jestProject', () => {
}); });
it('should create a tsconfig.spec.json', async () => { it('should create a tsconfig.spec.json', async () => {
await jestProjectGenerator(tree, { await configurationGenerator(tree, {
...defaultOptions, ...defaultOptions,
project: 'lib1', project: 'lib1',
setupFile: 'angular', setupFile: 'angular',
@ -132,7 +132,7 @@ describe('jestProject', () => {
describe('--setup-file', () => { describe('--setup-file', () => {
it('should generate src/test-setup.ts', async () => { it('should generate src/test-setup.ts', async () => {
await jestProjectGenerator(tree, { await configurationGenerator(tree, {
...defaultOptions, ...defaultOptions,
project: 'lib1', project: 'lib1',
} as JestProjectSchema); } as JestProjectSchema);
@ -143,7 +143,7 @@ describe('jestProject', () => {
}); });
it('should have setupFilesAfterEnv in the jest.config when generated for web-components', async () => { it('should have setupFilesAfterEnv in the jest.config when generated for web-components', async () => {
await jestProjectGenerator(tree, { await configurationGenerator(tree, {
...defaultOptions, ...defaultOptions,
project: 'lib1', project: 'lib1',
setupFile: 'web-components', setupFile: 'web-components',
@ -154,7 +154,7 @@ describe('jestProject', () => {
}); });
it('should have setupFilesAfterEnv and globals.ts-jest in the jest.config when generated for angular', async () => { it('should have setupFilesAfterEnv and globals.ts-jest in the jest.config when generated for angular', async () => {
await jestProjectGenerator(tree, { await configurationGenerator(tree, {
...defaultOptions, ...defaultOptions,
project: 'lib1', project: 'lib1',
setupFile: 'angular', setupFile: 'angular',
@ -168,7 +168,7 @@ describe('jestProject', () => {
}); });
it('should not list the setup file in project configuration', async () => { it('should not list the setup file in project configuration', async () => {
await jestProjectGenerator(tree, { await configurationGenerator(tree, {
...defaultOptions, ...defaultOptions,
project: 'lib1', project: 'lib1',
setupFile: 'none', setupFile: 'none',
@ -178,7 +178,7 @@ describe('jestProject', () => {
}); });
it('should not list the setup file in tsconfig.spec.json', async () => { it('should not list the setup file in tsconfig.spec.json', async () => {
await jestProjectGenerator(tree, { await configurationGenerator(tree, {
...defaultOptions, ...defaultOptions,
project: 'lib1', project: 'lib1',
setupFile: 'none', setupFile: 'none',
@ -190,7 +190,7 @@ describe('jestProject', () => {
describe('--skip-setup-file', () => { describe('--skip-setup-file', () => {
it('should generate src/test-setup.ts', async () => { it('should generate src/test-setup.ts', async () => {
await jestProjectGenerator(tree, { await configurationGenerator(tree, {
...defaultOptions, ...defaultOptions,
project: 'lib1', project: 'lib1',
skipSetupFile: true, skipSetupFile: true,
@ -199,7 +199,7 @@ describe('jestProject', () => {
}); });
it('should not list the setup file in project configuration', async () => { it('should not list the setup file in project configuration', async () => {
await jestProjectGenerator(tree, { await configurationGenerator(tree, {
...defaultOptions, ...defaultOptions,
project: 'lib1', project: 'lib1',
skipSetupFile: true, skipSetupFile: true,
@ -209,7 +209,7 @@ describe('jestProject', () => {
}); });
it('should not list the setup file in tsconfig.spec.json', async () => { it('should not list the setup file in tsconfig.spec.json', async () => {
await jestProjectGenerator(tree, { await configurationGenerator(tree, {
...defaultOptions, ...defaultOptions,
project: 'lib1', project: 'lib1',
skipSetupFile: true, skipSetupFile: true,
@ -221,7 +221,7 @@ describe('jestProject', () => {
describe('--skip-serializers', () => { describe('--skip-serializers', () => {
it('should not list the serializers in jest.config.ts', async () => { it('should not list the serializers in jest.config.ts', async () => {
await jestProjectGenerator(tree, { await configurationGenerator(tree, {
...defaultOptions, ...defaultOptions,
project: 'lib1', project: 'lib1',
skipSerializers: true, skipSerializers: true,
@ -239,7 +239,7 @@ describe('jestProject', () => {
describe('--support-tsx', () => { describe('--support-tsx', () => {
it('should add jest.transform', async () => { it('should add jest.transform', async () => {
await jestProjectGenerator(tree, { await configurationGenerator(tree, {
...defaultOptions, ...defaultOptions,
project: 'lib1', project: 'lib1',
supportTsx: true, supportTsx: true,
@ -254,7 +254,7 @@ describe('jestProject', () => {
}); });
it('should add tsx to moduleExtensions', async () => { it('should add tsx to moduleExtensions', async () => {
await jestProjectGenerator(tree, { await configurationGenerator(tree, {
...defaultOptions, ...defaultOptions,
project: 'lib1', project: 'lib1',
supportTsx: true, supportTsx: true,
@ -270,7 +270,7 @@ describe('jestProject', () => {
}); });
it('should create jest.config.js with --js flag', async () => { it('should create jest.config.js with --js flag', async () => {
await jestProjectGenerator(tree, { await configurationGenerator(tree, {
...defaultOptions, ...defaultOptions,
project: 'lib1', project: 'lib1',
js: true, js: true,
@ -284,7 +284,7 @@ describe('jestProject', () => {
}); });
it('should use jest.config.js in project config with --js flag', async () => { it('should use jest.config.js in project config with --js flag', async () => {
await jestProjectGenerator(tree, { await configurationGenerator(tree, {
...defaultOptions, ...defaultOptions,
project: 'lib1', project: 'lib1',
js: true, js: true,
@ -297,7 +297,7 @@ describe('jestProject', () => {
it('should always use jest.preset.js with --js', async () => { it('should always use jest.preset.js with --js', async () => {
tree.write('jest.preset.ts', ''); tree.write('jest.preset.ts', '');
await jestProjectGenerator(tree, { await configurationGenerator(tree, {
...defaultOptions, ...defaultOptions,
project: 'lib1', project: 'lib1',
js: true, js: true,
@ -309,7 +309,7 @@ describe('jestProject', () => {
}); });
it('should use module.exports with --js flag', async () => { it('should use module.exports with --js flag', async () => {
await jestProjectGenerator(tree, { await configurationGenerator(tree, {
...defaultOptions, ...defaultOptions,
project: 'lib1', project: 'lib1',
js: true, js: true,
@ -322,7 +322,7 @@ describe('jestProject', () => {
describe('--babelJest', () => { describe('--babelJest', () => {
it('should generate proper jest.transform when babelJest is true', async () => { it('should generate proper jest.transform when babelJest is true', async () => {
await jestProjectGenerator(tree, { await configurationGenerator(tree, {
...defaultOptions, ...defaultOptions,
project: 'lib1', project: 'lib1',
babelJest: true, babelJest: true,
@ -338,7 +338,7 @@ describe('jestProject', () => {
}); });
it('should generate proper jest.transform when babelJest and supportTsx is true', async () => { it('should generate proper jest.transform when babelJest and supportTsx is true', async () => {
await jestProjectGenerator(tree, { await configurationGenerator(tree, {
...defaultOptions, ...defaultOptions,
project: 'lib1', project: 'lib1',
babelJest: true, babelJest: true,
@ -348,7 +348,7 @@ describe('jestProject', () => {
}); });
it('should generate proper jest.transform when --compiler=swc and supportTsx is true', async () => { it('should generate proper jest.transform when --compiler=swc and supportTsx is true', async () => {
await jestProjectGenerator(tree, { await configurationGenerator(tree, {
...defaultOptions, ...defaultOptions,
project: 'lib1', project: 'lib1',
compiler: 'swc', compiler: 'swc',
@ -371,7 +371,7 @@ describe('jestProject', () => {
name: 'my-project', name: 'my-project',
targets: {}, targets: {},
}); });
await jestProjectGenerator(tree, { await configurationGenerator(tree, {
...defaultOptions, ...defaultOptions,
project: 'my-project', project: 'my-project',
}); });
@ -402,7 +402,7 @@ describe('jestProject', () => {
name: 'my-project', name: 'my-project',
targets: {}, targets: {},
}); });
await jestProjectGenerator(tree, { await configurationGenerator(tree, {
...defaultOptions, ...defaultOptions,
project: 'my-project', project: 'my-project',
js: true, js: true,

View File

@ -56,7 +56,7 @@ function normalizeOptions(
}; };
} }
export async function jestProjectGenerator( export async function configurationGenerator(
tree: Tree, tree: Tree,
schema: JestProjectSchema schema: JestProjectSchema
): Promise<GeneratorCallback> { ): Promise<GeneratorCallback> {
@ -74,4 +74,6 @@ export async function jestProjectGenerator(
return installTask; return installTask;
} }
export const jestProjectSchematic = convertNxGenerator(jestProjectGenerator); export default configurationGenerator;
export const compat = convertNxGenerator(configurationGenerator);

View File

@ -68,7 +68,7 @@ function createJestConfig(tree: Tree, options: NormalizedSchema) {
addTestInputs(tree); addTestInputs(tree);
} }
if (options.rootProject) { if (options.rootProject) {
// we don't want any config to be made because the `jestProjectGenerator` // we don't want any config to be made because the `configurationGenerator` will do it.
// will copy the template config file // will copy the template config file
return; return;
} }

View File

@ -366,8 +366,8 @@ async function addJest(
tree: Tree, tree: Tree,
options: NormalizedSchema options: NormalizedSchema
): Promise<GeneratorCallback> { ): Promise<GeneratorCallback> {
const { jestProjectGenerator } = ensurePackage('@nx/jest', nxVersion); const { configurationGenerator } = ensurePackage('@nx/jest', nxVersion);
return await jestProjectGenerator(tree, { return await configurationGenerator(tree, {
...options, ...options,
project: options.name, project: options.name,
setupFile: 'none', setupFile: 'none',

View File

@ -30,10 +30,9 @@ export async function lintWorkspaceRulesProjectGenerator(
tree: Tree, tree: Tree,
options: LintWorkspaceRulesProjectGeneratorOptions = {} options: LintWorkspaceRulesProjectGeneratorOptions = {}
) { ) {
const { addPropertyToJestConfig, jestProjectGenerator } = ensurePackage( const { addPropertyToJestConfig, configurationGenerator } = ensurePackage<
'@nx/jest', typeof import('@nx/jest')
nxVersion >('@nx/jest', nxVersion);
);
// Noop if the workspace rules project already exists // Noop if the workspace rules project already exists
try { try {
@ -70,7 +69,7 @@ export async function lintWorkspaceRulesProjectGenerator(
} }
// Add jest to the project and return installation task // Add jest to the project and return installation task
const installTask = await jestProjectGenerator(tree, { const installTask = await configurationGenerator(tree, {
project: WORKSPACE_RULES_PROJECT_NAME, project: WORKSPACE_RULES_PROJECT_NAME,
supportTsx: false, supportTsx: false,
skipSerializers: true, skipSerializers: true,

View File

@ -14,11 +14,11 @@ export async function addJest(host: Tree, options: NormalizedSchema) {
return () => {}; return () => {};
} }
const { jestProjectGenerator } = ensurePackage<typeof import('@nx/jest')>( const { configurationGenerator } = ensurePackage<typeof import('@nx/jest')>(
'@nx/jest', '@nx/jest',
nxVersion nxVersion
); );
const jestTask = await jestProjectGenerator(host, { const jestTask = await configurationGenerator(host, {
...options, ...options,
project: options.projectName, project: options.projectName,
supportTsx: true, supportTsx: true,

View File

@ -23,7 +23,7 @@ import {
updateTsConfigsToJs, updateTsConfigsToJs,
} from '@nx/devkit'; } from '@nx/devkit';
import { Linter, lintProjectGenerator } from '@nx/linter'; import { Linter, lintProjectGenerator } from '@nx/linter';
import { jestProjectGenerator } from '@nx/jest'; import { configurationGenerator } from '@nx/jest';
import { getRelativePathToRootTsConfig, tsConfigBaseOptions } from '@nx/js'; import { getRelativePathToRootTsConfig, tsConfigBaseOptions } from '@nx/js';
import { join } from 'path'; import { join } from 'path';
@ -391,7 +391,7 @@ export async function applicationGenerator(tree: Tree, schema: Schema) {
} }
if (options.unitTestRunner === 'jest') { if (options.unitTestRunner === 'jest') {
const jestTask = await jestProjectGenerator(tree, { const jestTask = await configurationGenerator(tree, {
...options, ...options,
project: options.name, project: options.name,
setupFile: 'none', setupFile: 'none',

View File

@ -16,7 +16,7 @@ import {
runTasksInSerial, runTasksInSerial,
updateProjectConfiguration, updateProjectConfiguration,
} from '@nx/devkit'; } from '@nx/devkit';
import { addPropertyToJestConfig, jestProjectGenerator } from '@nx/jest'; import { addPropertyToJestConfig, configurationGenerator } from '@nx/jest';
import { getRelativePathToRootTsConfig } from '@nx/js'; import { getRelativePathToRootTsConfig } from '@nx/js';
import { setupVerdaccio } from '@nx/js/src/generators/setup-verdaccio/generator'; import { setupVerdaccio } from '@nx/js/src/generators/setup-verdaccio/generator';
import { addLocalRegistryScripts } from '@nx/js/src/utils/add-local-registry-scripts'; import { addLocalRegistryScripts } from '@nx/js/src/utils/add-local-registry-scripts';
@ -93,7 +93,7 @@ async function addJest(host: Tree, options: NormalizedSchema) {
implicitDependencies: [options.pluginName], implicitDependencies: [options.pluginName],
}); });
const jestTask = await jestProjectGenerator(host, { const jestTask = await configurationGenerator(host, {
project: options.projectName, project: options.projectName,
setupFile: 'none', setupFile: 'none',
supportTsx: false, supportTsx: false,

View File

@ -1,5 +1,5 @@
import { Tree } from '@nx/devkit'; import { Tree } from '@nx/devkit';
import { jestProjectGenerator } from '@nx/jest'; import { configurationGenerator } from '@nx/jest';
export async function addJest( export async function addJest(
host: Tree, host: Tree,
@ -13,7 +13,7 @@ export async function addJest(
return () => {}; return () => {};
} }
const jestTask = await jestProjectGenerator(host, { const jestTask = await configurationGenerator(host, {
js, js,
project: projectName, project: projectName,
supportTsx: true, supportTsx: true,

View File

@ -6,7 +6,7 @@ export async function addJest(
host: Tree, host: Tree,
options: NormalizedSchema options: NormalizedSchema
): Promise<GeneratorCallback> { ): Promise<GeneratorCallback> {
const { jestProjectGenerator } = ensurePackage<typeof import('@nx/jest')>( const { configurationGenerator } = ensurePackage<typeof import('@nx/jest')>(
'@nx/jest', '@nx/jest',
nxVersion nxVersion
); );
@ -15,7 +15,7 @@ export async function addJest(
return () => {}; return () => {};
} }
return await jestProjectGenerator(host, { return await configurationGenerator(host, {
...options, ...options,
project: options.projectName, project: options.projectName,
supportTsx: true, supportTsx: true,

View File

@ -84,12 +84,12 @@ export async function libraryGenerator(host: Tree, schema: Schema) {
// Set up test target // Set up test target
if (options.unitTestRunner === 'jest') { if (options.unitTestRunner === 'jest') {
const { jestProjectGenerator } = ensurePackage<typeof import('@nx/jest')>( const { configurationGenerator } = ensurePackage<typeof import('@nx/jest')>(
'@nx/jest', '@nx/jest',
nxVersion nxVersion
); );
const jestTask = await jestProjectGenerator(host, { const jestTask = await configurationGenerator(host, {
...options, ...options,
project: options.name, project: options.name,
setupFile: 'none', setupFile: 'none',

View File

@ -273,10 +273,10 @@ export async function applicationGenerator(host: Tree, schema: Schema) {
tasks.push(cypressTask); tasks.push(cypressTask);
} }
if (options.unitTestRunner === 'jest') { if (options.unitTestRunner === 'jest') {
const { jestProjectGenerator } = await ensurePackage< const { configurationGenerator } = await ensurePackage<
typeof import('@nx/jest') typeof import('@nx/jest')
>('@nx/jest', nxVersion); >('@nx/jest', nxVersion);
const jestTask = await jestProjectGenerator(host, { const jestTask = await configurationGenerator(host, {
project: options.projectName, project: options.projectName,
skipSerializers: true, skipSerializers: true,
setupFile: 'web-components', setupFile: 'web-components',