feat(storybook): add projectNameAndRootFormat as-provided in tests (#18936)
This commit is contained in:
parent
a2493b92f8
commit
b17b30d13b
@ -12,7 +12,9 @@ describe('Storybook executors for Angular', () => {
|
|||||||
const angularStorybookLib = uniq('test-ui-ng-lib');
|
const angularStorybookLib = uniq('test-ui-ng-lib');
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
newProject();
|
newProject();
|
||||||
runCLI(`g @nx/angular:library ${angularStorybookLib} --no-interactive`);
|
runCLI(
|
||||||
|
`g @nx/angular:library ${angularStorybookLib} --project-name-and-root-format=as-provided --no-interactive`
|
||||||
|
);
|
||||||
runCLI(
|
runCLI(
|
||||||
`generate @nx/angular:storybook-configuration ${angularStorybookLib} --generateStories --no-interactive`
|
`generate @nx/angular:storybook-configuration ${angularStorybookLib} --generateStories --no-interactive`
|
||||||
);
|
);
|
||||||
|
|||||||
@ -72,7 +72,7 @@ describe('Storybook generators and executors for standalone workspaces - using R
|
|||||||
|
|
||||||
it('should build a React based storybook that references another lib and uses Vite', () => {
|
it('should build a React based storybook that references another lib and uses Vite', () => {
|
||||||
runCLI(
|
runCLI(
|
||||||
`generate @nx/react:lib my-lib --bundler=vite --unitTestRunner=none --no-interactive`
|
`generate @nx/react:lib my-lib --bundler=vite --unitTestRunner=none --project-name-and-root-format=as-provided --no-interactive`
|
||||||
);
|
);
|
||||||
|
|
||||||
// create a component and a story in the first lib to reference the cmp from the 2nd lib
|
// create a component and a story in the first lib to reference the cmp from the 2nd lib
|
||||||
|
|||||||
@ -18,7 +18,7 @@ describe('Storybook generators and executors for monorepos', () => {
|
|||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
proj = newProject();
|
proj = newProject();
|
||||||
runCLI(
|
runCLI(
|
||||||
`generate @nx/react:app ${reactStorybookApp} --bundler=webpack --no-interactive`
|
`generate @nx/react:app ${reactStorybookApp} --bundler=webpack --project-name-and-root-format=as-provided --no-interactive`
|
||||||
);
|
);
|
||||||
await setMaxWorkers();
|
await setMaxWorkers();
|
||||||
runCLI(
|
runCLI(
|
||||||
@ -55,15 +55,15 @@ describe('Storybook generators and executors for monorepos', () => {
|
|||||||
// This test makes sure path resolution works
|
// This test makes sure path resolution works
|
||||||
it('should build a React based storybook that references another lib and uses rollup', () => {
|
it('should build a React based storybook that references another lib and uses rollup', () => {
|
||||||
runCLI(
|
runCLI(
|
||||||
`generate @nx/react:lib my-lib --bundler=rollup --unitTestRunner=none --no-interactive`
|
`generate @nx/react:lib my-lib --bundler=rollup --unitTestRunner=none --project-name-and-root-format=as-provided --no-interactive`
|
||||||
);
|
);
|
||||||
|
|
||||||
// create a component in the first lib to reference the cmp from the 2nd lib
|
// create a component in the first lib to reference the cmp from the 2nd lib
|
||||||
createFileSync(
|
createFileSync(
|
||||||
tmpProjPath(`apps/${reactStorybookApp}/src/app/test-button.tsx`)
|
tmpProjPath(`${reactStorybookApp}/src/app/test-button.tsx`)
|
||||||
);
|
);
|
||||||
writeFileSync(
|
writeFileSync(
|
||||||
tmpProjPath(`apps/${reactStorybookApp}/src/app/test-button.tsx`),
|
tmpProjPath(`${reactStorybookApp}/src/app/test-button.tsx`),
|
||||||
`
|
`
|
||||||
import { MyLib } from '@${proj}/my-lib';
|
import { MyLib } from '@${proj}/my-lib';
|
||||||
|
|
||||||
@ -81,12 +81,10 @@ describe('Storybook generators and executors for monorepos', () => {
|
|||||||
|
|
||||||
// create a story in the first lib to reference the cmp from the 2nd lib
|
// create a story in the first lib to reference the cmp from the 2nd lib
|
||||||
createFileSync(
|
createFileSync(
|
||||||
tmpProjPath(`apps/${reactStorybookApp}/src/app/test-button.stories.tsx`)
|
tmpProjPath(`${reactStorybookApp}/src/app/test-button.stories.tsx`)
|
||||||
);
|
);
|
||||||
writeFileSync(
|
writeFileSync(
|
||||||
tmpProjPath(
|
tmpProjPath(`${reactStorybookApp}/src/app/test-button.stories.tsx`),
|
||||||
`apps/${reactStorybookApp}/src/app/test-button.stories.tsx`
|
|
||||||
),
|
|
||||||
`
|
`
|
||||||
import type { Meta } from '@storybook/react';
|
import type { Meta } from '@storybook/react';
|
||||||
import { TestButton } from './test-button';
|
import { TestButton } from './test-button';
|
||||||
|
|||||||
@ -22,11 +22,11 @@ export default config;
|
|||||||
|
|
||||||
exports[`@nx/storybook:configuration for Storybook v7 basic functionalities should generate TypeScript Configuration files by default 1`] = `
|
exports[`@nx/storybook:configuration for Storybook v7 basic functionalities should generate TypeScript Configuration files by default 1`] = `
|
||||||
{
|
{
|
||||||
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
"$schema": "../node_modules/nx/schemas/project-schema.json",
|
||||||
"name": "test-ui-lib",
|
"name": "test-ui-lib",
|
||||||
"projectType": "library",
|
"projectType": "library",
|
||||||
"root": "libs/test-ui-lib",
|
"root": "test-ui-lib",
|
||||||
"sourceRoot": "libs/test-ui-lib/src",
|
"sourceRoot": "test-ui-lib/src",
|
||||||
"tags": [],
|
"tags": [],
|
||||||
"targets": {
|
"targets": {
|
||||||
"build-storybook": {
|
"build-storybook": {
|
||||||
@ -39,7 +39,7 @@ exports[`@nx/storybook:configuration for Storybook v7 basic functionalities shou
|
|||||||
"options": {
|
"options": {
|
||||||
"browserTarget": "test-ui-lib:build-storybook",
|
"browserTarget": "test-ui-lib:build-storybook",
|
||||||
"compodoc": false,
|
"compodoc": false,
|
||||||
"configDir": "libs/test-ui-lib/.storybook",
|
"configDir": "test-ui-lib/.storybook",
|
||||||
"outputDir": "dist/storybook/test-ui-lib",
|
"outputDir": "dist/storybook/test-ui-lib",
|
||||||
},
|
},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@ -50,7 +50,7 @@ exports[`@nx/storybook:configuration for Storybook v7 basic functionalities shou
|
|||||||
"executor": "@nx/linter:eslint",
|
"executor": "@nx/linter:eslint",
|
||||||
"options": {
|
"options": {
|
||||||
"lintFilePatterns": [
|
"lintFilePatterns": [
|
||||||
"libs/test-ui-lib/**/*.ts",
|
"test-ui-lib/**/*.ts",
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@ -67,7 +67,7 @@ exports[`@nx/storybook:configuration for Storybook v7 basic functionalities shou
|
|||||||
"options": {
|
"options": {
|
||||||
"browserTarget": "test-ui-lib:build-storybook",
|
"browserTarget": "test-ui-lib:build-storybook",
|
||||||
"compodoc": false,
|
"compodoc": false,
|
||||||
"configDir": "libs/test-ui-lib/.storybook",
|
"configDir": "test-ui-lib/.storybook",
|
||||||
"port": 4400,
|
"port": 4400,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -80,7 +80,7 @@ exports[`@nx/storybook:configuration for Storybook v7 basic functionalities shou
|
|||||||
},
|
},
|
||||||
"executor": "@nx/jest:jest",
|
"executor": "@nx/jest:jest",
|
||||||
"options": {
|
"options": {
|
||||||
"jestConfig": "libs/test-ui-lib/jest.config.ts",
|
"jestConfig": "test-ui-lib/jest.config.ts",
|
||||||
"passWithNoTests": true,
|
"passWithNoTests": true,
|
||||||
},
|
},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
@ -90,7 +90,7 @@ exports[`@nx/storybook:configuration for Storybook v7 basic functionalities shou
|
|||||||
"test-storybook": {
|
"test-storybook": {
|
||||||
"executor": "nx:run-commands",
|
"executor": "nx:run-commands",
|
||||||
"options": {
|
"options": {
|
||||||
"command": "test-storybook -c libs/test-ui-lib/.storybook --url=http://localhost:4400",
|
"command": "test-storybook -c test-ui-lib/.storybook --url=http://localhost:4400",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -127,9 +127,9 @@ exports[`@nx/storybook:configuration for Storybook v7 basic functionalities shou
|
|||||||
"outDir": ""
|
"outDir": ""
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"../../node_modules/@nx/react/typings/styled-jsx.d.ts",
|
"../node_modules/@nx/react/typings/styled-jsx.d.ts",
|
||||||
"../../node_modules/@nx/react/typings/cssmodule.d.ts",
|
"../node_modules/@nx/react/typings/cssmodule.d.ts",
|
||||||
"../../node_modules/@nx/react/typings/image.d.ts"
|
"../node_modules/@nx/react/typings/image.d.ts"
|
||||||
],
|
],
|
||||||
"exclude": [
|
"exclude": [
|
||||||
"src/**/*.spec.ts",
|
"src/**/*.spec.ts",
|
||||||
|
|||||||
@ -41,6 +41,7 @@ describe('@nx/storybook:configuration for Storybook v7', () => {
|
|||||||
await libraryGenerator(tree, {
|
await libraryGenerator(tree, {
|
||||||
name: 'test-ui-lib',
|
name: 'test-ui-lib',
|
||||||
bundler: 'none',
|
bundler: 'none',
|
||||||
|
projectNameAndRootFormat: 'as-provided',
|
||||||
});
|
});
|
||||||
writeJson(tree, 'package.json', {
|
writeJson(tree, 'package.json', {
|
||||||
devDependencies: {
|
devDependencies: {
|
||||||
@ -66,15 +67,11 @@ describe('@nx/storybook:configuration for Storybook v7', () => {
|
|||||||
expect(project).toMatchSnapshot();
|
expect(project).toMatchSnapshot();
|
||||||
|
|
||||||
expect(tree.read('.storybook/main.ts', 'utf-8')).toMatchSnapshot();
|
expect(tree.read('.storybook/main.ts', 'utf-8')).toMatchSnapshot();
|
||||||
|
expect(tree.exists('test-ui-lib/tsconfig.storybook.json')).toBeFalsy();
|
||||||
expect(
|
expect(
|
||||||
tree.exists('libs/test-ui-lib/tsconfig.storybook.json')
|
tree.read('test-ui-lib/.storybook/main.ts', 'utf-8')
|
||||||
).toBeFalsy();
|
|
||||||
expect(
|
|
||||||
tree.read('libs/test-ui-lib/.storybook/main.ts', 'utf-8')
|
|
||||||
).toMatchSnapshot();
|
).toMatchSnapshot();
|
||||||
expect(
|
expect(tree.exists('test-ui-lib/.storybook/preview.ts')).toBeTruthy();
|
||||||
tree.exists('libs/test-ui-lib/.storybook/preview.ts')
|
|
||||||
).toBeTruthy();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should update `tsconfig.lib.json` file', async () => {
|
it('should update `tsconfig.lib.json` file', async () => {
|
||||||
@ -85,7 +82,7 @@ describe('@nx/storybook:configuration for Storybook v7', () => {
|
|||||||
});
|
});
|
||||||
const tsconfigJson = readJson<TsConfig>(
|
const tsconfigJson = readJson<TsConfig>(
|
||||||
tree,
|
tree,
|
||||||
'libs/test-ui-lib/tsconfig.lib.json'
|
'test-ui-lib/tsconfig.lib.json'
|
||||||
) as Required<TsConfig>;
|
) as Required<TsConfig>;
|
||||||
|
|
||||||
expect(tsconfigJson.exclude).toContain('**/*.stories.ts');
|
expect(tsconfigJson.exclude).toContain('**/*.stories.ts');
|
||||||
@ -102,7 +99,7 @@ describe('@nx/storybook:configuration for Storybook v7', () => {
|
|||||||
});
|
});
|
||||||
const tsconfigJson = readJson<TsConfig>(
|
const tsconfigJson = readJson<TsConfig>(
|
||||||
tree,
|
tree,
|
||||||
'libs/test-ui-lib/tsconfig.json'
|
'test-ui-lib/tsconfig.json'
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(tsconfigJson.references).toMatchInlineSnapshot(`
|
expect(tsconfigJson.references).toMatchInlineSnapshot(`
|
||||||
@ -124,9 +121,10 @@ describe('@nx/storybook:configuration for Storybook v7', () => {
|
|||||||
await libraryGenerator(tree, {
|
await libraryGenerator(tree, {
|
||||||
name: 'test-ui-lib2',
|
name: 'test-ui-lib2',
|
||||||
linter: Linter.EsLint,
|
linter: Linter.EsLint,
|
||||||
|
projectNameAndRootFormat: 'as-provided',
|
||||||
});
|
});
|
||||||
|
|
||||||
updateJson(tree, 'libs/test-ui-lib2/.eslintrc.json', (json) => {
|
updateJson(tree, 'test-ui-lib2/.eslintrc.json', (json) => {
|
||||||
json.parserOptions = {
|
json.parserOptions = {
|
||||||
project: [],
|
project: [],
|
||||||
};
|
};
|
||||||
@ -139,11 +137,11 @@ describe('@nx/storybook:configuration for Storybook v7', () => {
|
|||||||
uiFramework: '@storybook/react-webpack5',
|
uiFramework: '@storybook/react-webpack5',
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(readJson(tree, 'libs/test-ui-lib2/.eslintrc.json').parserOptions)
|
expect(readJson(tree, 'test-ui-lib2/.eslintrc.json').parserOptions)
|
||||||
.toMatchInlineSnapshot(`
|
.toMatchInlineSnapshot(`
|
||||||
{
|
{
|
||||||
"project": [
|
"project": [
|
||||||
"libs/test-ui-lib2/tsconfig.storybook.json",
|
"test-ui-lib2/tsconfig.storybook.json",
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
`);
|
`);
|
||||||
@ -153,6 +151,7 @@ describe('@nx/storybook:configuration for Storybook v7', () => {
|
|||||||
await libraryGenerator(tree, {
|
await libraryGenerator(tree, {
|
||||||
name: 'test-ui-lib2',
|
name: 'test-ui-lib2',
|
||||||
linter: Linter.EsLint,
|
linter: Linter.EsLint,
|
||||||
|
projectNameAndRootFormat: 'as-provided',
|
||||||
});
|
});
|
||||||
|
|
||||||
await configurationGenerator(tree, {
|
await configurationGenerator(tree, {
|
||||||
@ -162,7 +161,7 @@ describe('@nx/storybook:configuration for Storybook v7', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
tree.read('libs/test-ui-lib2/tsconfig.storybook.json', 'utf-8')
|
tree.read('test-ui-lib2/tsconfig.storybook.json', 'utf-8')
|
||||||
).toMatchSnapshot();
|
).toMatchSnapshot();
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
@ -178,13 +177,11 @@ describe('@nx/storybook:configuration for Storybook v7', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
tree.read('libs/test-ui-lib/.storybook/main.ts', 'utf-8')
|
tree.read('test-ui-lib/.storybook/main.ts', 'utf-8')
|
||||||
).toMatchSnapshot();
|
).toMatchSnapshot();
|
||||||
expect(
|
expect(tree.exists('test-ui-lib/.storybook/preview.ts')).toBeTruthy();
|
||||||
tree.exists('libs/test-ui-lib/.storybook/preview.ts')
|
expect(tree.exists('test-ui-lib/.storybook/main.js')).toBeFalsy();
|
||||||
).toBeTruthy();
|
expect(tree.exists('test-ui-lib/.storybook/preview.js')).toBeFalsy();
|
||||||
expect(tree.exists('libs/test-ui-lib/.storybook/main.js')).toBeFalsy();
|
|
||||||
expect(tree.exists('libs/test-ui-lib/.storybook/preview.js')).toBeFalsy();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should add test-storybook target', async () => {
|
it('should add test-storybook target', async () => {
|
||||||
@ -223,7 +220,7 @@ describe('@nx/storybook:configuration for Storybook v7', () => {
|
|||||||
executor: 'nx:run-commands',
|
executor: 'nx:run-commands',
|
||||||
options: {
|
options: {
|
||||||
command:
|
command:
|
||||||
'test-storybook -c libs/test-ui-lib/.storybook --url=http://localhost:4400',
|
'test-storybook -c test-ui-lib/.storybook --url=http://localhost:4400',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -17,6 +17,7 @@ describe('@nx/storybook:cypress-project', () => {
|
|||||||
tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
|
tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
|
||||||
await libraryGenerator(tree, {
|
await libraryGenerator(tree, {
|
||||||
name: 'test-ui-lib',
|
name: 'test-ui-lib',
|
||||||
|
projectNameAndRootFormat: 'as-provided',
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
afterEach(() => jest.clearAllMocks());
|
afterEach(() => jest.clearAllMocks());
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user