@nx/react 0.0.0-pr-31172-da609d4 → 0.0.0-pr-31163-1e9ab14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +6 -6
- package/src/generators/component-story/files/jsx/__componentFileName__.stories.jsx__tmpl__ +6 -4
- package/src/generators/component-story/files/tsx/__componentFileName__.stories.tsx__tmpl__ +6 -4
- package/src/generators/stories/stories.d.ts +2 -2
- package/src/generators/stories/stories.js +8 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/react",
|
|
3
|
-
"version": "0.0.0-pr-
|
|
3
|
+
"version": "0.0.0-pr-31163-1e9ab14",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The React plugin for Nx contains executors and generators for managing React applications and libraries within an Nx workspace. It provides:\n\n\n- Integration with libraries such as Jest, Vitest, Playwright, Cypress, and Storybook.\n\n- Generators for applications, libraries, components, hooks, and more.\n\n- Library build support for publishing packages to npm or other registries.\n\n- Utilities for automatic workspace refactoring.",
|
|
6
6
|
"repository": {
|
|
@@ -38,11 +38,11 @@
|
|
|
38
38
|
"minimatch": "9.0.3",
|
|
39
39
|
"picocolors": "^1.1.0",
|
|
40
40
|
"tslib": "^2.3.0",
|
|
41
|
-
"@nx/devkit": "0.0.0-pr-
|
|
42
|
-
"@nx/js": "0.0.0-pr-
|
|
43
|
-
"@nx/eslint": "0.0.0-pr-
|
|
44
|
-
"@nx/web": "0.0.0-pr-
|
|
45
|
-
"@nx/module-federation": "0.0.0-pr-
|
|
41
|
+
"@nx/devkit": "0.0.0-pr-31163-1e9ab14",
|
|
42
|
+
"@nx/js": "0.0.0-pr-31163-1e9ab14",
|
|
43
|
+
"@nx/eslint": "0.0.0-pr-31163-1e9ab14",
|
|
44
|
+
"@nx/web": "0.0.0-pr-31163-1e9ab14",
|
|
45
|
+
"@nx/module-federation": "0.0.0-pr-31163-1e9ab14",
|
|
46
46
|
"express": "^4.21.2",
|
|
47
47
|
"http-proxy-middleware": "^3.0.3",
|
|
48
48
|
"semver": "^7.6.3"
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import componentName from './<%= componentImportFileName %>';
|
|
2
2
|
<%_ if ( interactionTests ) { _%>
|
|
3
|
-
import {
|
|
3
|
+
import { within } from '@storybook/testing-library';
|
|
4
|
+
import { expect } from '@storybook/jest';
|
|
4
5
|
<%_ } _%>
|
|
5
6
|
|
|
6
7
|
export default {
|
|
@@ -20,8 +21,9 @@ export const Primary = {
|
|
|
20
21
|
|
|
21
22
|
<%_ if ( interactionTests ) { _%>
|
|
22
23
|
export const Heading: Story = {
|
|
23
|
-
play: async ({
|
|
24
|
-
|
|
24
|
+
play: async ({ canvasElement }) => {
|
|
25
|
+
const canvas = within(canvasElement);
|
|
26
|
+
expect(canvas.getByText(/Welcome to <%=componentName%>!/gi)).toBeTruthy();
|
|
25
27
|
},
|
|
26
28
|
};
|
|
27
|
-
<%_ } _%>
|
|
29
|
+
<%_ } _%>
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from 'storybook/
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
2
|
import { <%= componentName %> } from './<%= componentImportFileName %>';
|
|
3
3
|
<%_ if ( interactionTests ) { _%>
|
|
4
|
-
import {
|
|
4
|
+
import { within } from '@storybook/testing-library';
|
|
5
|
+
import { expect } from '@storybook/jest';
|
|
5
6
|
<%_ } _%>
|
|
6
7
|
|
|
7
8
|
const meta: Meta<typeof <%= componentName %>> = {
|
|
@@ -26,8 +27,9 @@ export const Heading: Story = {
|
|
|
26
27
|
args: {<% for (let prop of props) { %>
|
|
27
28
|
<%= prop.name %>: <%- prop.defaultValue %>,<% } %>
|
|
28
29
|
},
|
|
29
|
-
play: async ({
|
|
30
|
-
|
|
30
|
+
play: async ({ canvasElement }) => {
|
|
31
|
+
const canvas = within(canvasElement);
|
|
32
|
+
expect(canvas.getByText(/Welcome to <%=componentName%>!/gi)).toBeTruthy();
|
|
31
33
|
},
|
|
32
34
|
};
|
|
33
35
|
<% } %>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ProjectConfiguration, Tree } from '@nx/devkit';
|
|
1
|
+
import { GeneratorCallback, ProjectConfiguration, Tree } from '@nx/devkit';
|
|
2
2
|
export interface StorybookStoriesSchema {
|
|
3
3
|
project: string;
|
|
4
4
|
interactionTests?: boolean;
|
|
@@ -9,5 +9,5 @@ export interface StorybookStoriesSchema {
|
|
|
9
9
|
export declare function projectRootPath(tree: Tree, config: ProjectConfiguration): Promise<string>;
|
|
10
10
|
export declare function containsComponentDeclaration(tree: Tree, componentPath: string): boolean;
|
|
11
11
|
export declare function createAllStories(tree: Tree, projectName: string, interactionTests: boolean, js: boolean, projects: Map<string, ProjectConfiguration>, projectConfiguration: ProjectConfiguration, ignorePaths?: string[]): Promise<void>;
|
|
12
|
-
export declare function storiesGenerator(host: Tree, schema: StorybookStoriesSchema): Promise<
|
|
12
|
+
export declare function storiesGenerator(host: Tree, schema: StorybookStoriesSchema): Promise<GeneratorCallback>;
|
|
13
13
|
export default storiesGenerator;
|
|
@@ -10,6 +10,7 @@ const devkit_1 = require("@nx/devkit");
|
|
|
10
10
|
const path_1 = require("path");
|
|
11
11
|
const minimatch_1 = require("minimatch");
|
|
12
12
|
const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
|
|
13
|
+
const versions_1 = require("../../utils/versions");
|
|
13
14
|
const ts_solution_setup_1 = require("@nx/js/src/utils/typescript/ts-solution-setup");
|
|
14
15
|
let tsModule;
|
|
15
16
|
async function projectRootPath(tree, config) {
|
|
@@ -90,9 +91,16 @@ async function storiesGenerator(host, schema) {
|
|
|
90
91
|
const projectConfiguration = projects.get(schema.project);
|
|
91
92
|
schema.interactionTests = schema.interactionTests ?? true;
|
|
92
93
|
await createAllStories(host, schema.project, schema.interactionTests, schema.js, projects, projectConfiguration, schema.ignorePaths);
|
|
94
|
+
const tasks = [];
|
|
95
|
+
if (schema.interactionTests) {
|
|
96
|
+
const { interactionTestsDependencies, addInteractionsInAddons } = (0, devkit_1.ensurePackage)('@nx/storybook', versions_1.nxVersion);
|
|
97
|
+
tasks.push((0, devkit_1.addDependenciesToPackageJson)(host, {}, interactionTestsDependencies()));
|
|
98
|
+
addInteractionsInAddons(host, projectConfiguration);
|
|
99
|
+
}
|
|
93
100
|
if (!schema.skipFormat) {
|
|
94
101
|
await (0, devkit_1.formatFiles)(host);
|
|
95
102
|
}
|
|
103
|
+
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
96
104
|
}
|
|
97
105
|
async function isNextJsProject(tree, config) {
|
|
98
106
|
const { findStorybookAndBuildTargetsAndCompiler } = await Promise.resolve().then(() => require('@nx/storybook/src/utils/utilities'));
|