fix(react): remove unit test runner prompt when generating library (#14457)
This commit is contained in:
parent
bd2b5ca8d3
commit
99b49189eb
@ -80,7 +80,8 @@
|
||||
"unitTestRunner": {
|
||||
"type": "string",
|
||||
"enum": ["jest", "vitest", "none"],
|
||||
"description": "Test runner to use for unit tests."
|
||||
"description": "Test runner to use for unit tests.",
|
||||
"x-prompt": "What unit test runner should be used?"
|
||||
},
|
||||
"inSourceTests": {
|
||||
"type": "boolean",
|
||||
|
||||
@ -36,7 +36,6 @@
|
||||
"@nrwl/workspace": "file:../workspace",
|
||||
"@phenomnomnominal/tsquery": "4.1.1",
|
||||
"chalk": "^4.1.0",
|
||||
"enquirer": "~2.3.6",
|
||||
"minimatch": "3.0.5",
|
||||
"semver": "7.3.4"
|
||||
},
|
||||
|
||||
@ -14,9 +14,6 @@ describe(componentTestGenerator.name, () => {
|
||||
> = assertMinimumCypressVersion as never;
|
||||
beforeEach(() => {
|
||||
tree = createTreeWithEmptyV1Workspace();
|
||||
jest
|
||||
.spyOn(enquirer, 'prompt')
|
||||
.mockReturnValue(new Promise((res) => res({ runner: 'jest' })));
|
||||
});
|
||||
it('should create component test for tsx files', async () => {
|
||||
mockedAssertMinimumCypressVersion.mockReturnValue();
|
||||
|
||||
@ -30,9 +30,6 @@ describe('React:CypressComponentTestConfiguration', () => {
|
||||
> = assertMinimumCypressVersion as never;
|
||||
beforeEach(() => {
|
||||
tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
|
||||
jest
|
||||
.spyOn(enquirer, 'prompt')
|
||||
.mockReturnValue(new Promise((res) => res({ runner: 'jest' })));
|
||||
});
|
||||
|
||||
it('should generate cypress config with vite', async () => {
|
||||
|
||||
@ -371,9 +371,6 @@ describe('lib', () => {
|
||||
|
||||
describe('--unit-test-runner none', () => {
|
||||
it('should not generate test configuration', async () => {
|
||||
jest
|
||||
.spyOn(enquirer, 'prompt')
|
||||
.mockReturnValue(new Promise((res) => res({ runner: 'none' })));
|
||||
await libraryGenerator(tree, {
|
||||
...defaultSchema,
|
||||
unitTestRunner: 'none',
|
||||
|
||||
@ -23,26 +23,11 @@ import { createFiles } from './lib/create-files';
|
||||
import { updateBaseTsConfig } from './lib/update-base-tsconfig';
|
||||
import { extractTsConfigBase } from '../../utils/create-ts-config';
|
||||
import { installCommonDependencies } from './lib/install-common-dependencies';
|
||||
import { prompt } from 'enquirer';
|
||||
import { setDefaults } from './lib/set-defaults';
|
||||
|
||||
export async function libraryGenerator(host: Tree, schema: Schema) {
|
||||
const tasks: GeneratorCallback[] = [];
|
||||
|
||||
// Check if unit test runner was provided or if we have a default
|
||||
if (!schema.unitTestRunner) {
|
||||
schema.unitTestRunner = (
|
||||
await prompt<{ runner: 'vitest' | 'jest' | 'none' }>([
|
||||
{
|
||||
message: 'What unit test runner should be used?',
|
||||
type: 'select',
|
||||
name: 'runner',
|
||||
choices: ['vitest', 'jest', 'none'],
|
||||
},
|
||||
])
|
||||
).runner;
|
||||
}
|
||||
|
||||
const options = normalizeOptions(host, schema);
|
||||
if (options.publishable === true && !schema.importPath) {
|
||||
throw new Error(
|
||||
|
||||
@ -83,7 +83,8 @@
|
||||
"unitTestRunner": {
|
||||
"type": "string",
|
||||
"enum": ["jest", "vitest", "none"],
|
||||
"description": "Test runner to use for unit tests."
|
||||
"description": "Test runner to use for unit tests.",
|
||||
"x-prompt": "What unit test runner should be used?"
|
||||
},
|
||||
"inSourceTests": {
|
||||
"type": "boolean",
|
||||
|
||||
@ -10,9 +10,6 @@ describe('react:stories for libraries', () => {
|
||||
let appTree: Tree;
|
||||
|
||||
beforeEach(async () => {
|
||||
jest
|
||||
.spyOn(enquirer, 'prompt')
|
||||
.mockReturnValue(new Promise((res) => res({ runner: 'jest' })));
|
||||
appTree = await createTestUILib('test-ui-lib');
|
||||
|
||||
// create another component
|
||||
|
||||
@ -25,9 +25,6 @@ describe('react:storybook-configuration', () => {
|
||||
mockedInstalledCypressVersion.mockReturnValue(10);
|
||||
jest.spyOn(logger, 'warn').mockImplementation(() => {});
|
||||
jest.spyOn(logger, 'debug').mockImplementation(() => {});
|
||||
jest
|
||||
.spyOn(enquirer, 'prompt')
|
||||
.mockReturnValue(new Promise((res) => res({ runner: 'jest' })));
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user