= (args: MyTestCmpComponent) => ({
- component: MyTestCmpComponent,
- props: args,
- });
-
-
- export const Primary = Template.bind({});
- Primary.args = {
- }
- `
- );
-
- // build Angular lib
- runCLI(`run ${angularStorybookLib}:build-storybook`);
- checkFilesExist(`dist/storybook/${angularStorybookLib}/index.html`);
- }, 1000000);
});
});
export function createTestUILib(libName: string): void {
- runCLI(
- `g @nrwl/angular:library ${libName} --no-interactive --buildable=true`
- );
+ runCLI(`g @nrwl/angular:library ${libName} --no-interactive`);
runCLI(
`g @nrwl/angular:component test-button --project=${libName} --no-interactive`
);
@@ -260,27 +120,18 @@ export function createTestUILib(libName: string): void {
writeFileSync(
tmpProjPath(`libs/${libName}/src/lib/test-button/test-button.component.ts`),
`
- import { Component, OnInit, Input } from '@angular/core';
-
- export type ButtonStyle = 'default' | 'primary' | 'accent';
-
- @Component({
- selector: 'proj-test-button',
- templateUrl: './test-button.component.html',
- styleUrls: ['./test-button.component.css']
- })
- export class TestButtonComponent implements OnInit {
- @Input('buttonType') buttonType = 'button';
- @Input() style: ButtonStyle = 'default';
- @Input() age!: number;
- @Input() isDisabled = false;
-
- constructor() { }
-
- ngOnInit() {
- }
-
- }
+ import { Component, Input } from '@angular/core';
+
+ @Component({
+ selector: 'proj-test-button',
+ templateUrl: './test-button.component.html',
+ styleUrls: ['./test-button.component.css'],
+ })
+ export class TestButtonComponent {
+ @Input() text = 'Click me';
+ @Input() color = '#ddffdd';
+ @Input() disabled = false;
+ }
`
);
@@ -289,8 +140,13 @@ export function createTestUILib(libName: string): void {
`libs/${libName}/src/lib/test-button/test-button.component.html`
),
`
-
- You are {{age}} years old.
+
`
);
runCLI(
diff --git a/e2e/storybook/src/storybook.test.ts b/e2e/storybook/src/storybook.test.ts
index ecfbc6bad6d9a..51351dfb48fa5 100644
--- a/e2e/storybook/src/storybook.test.ts
+++ b/e2e/storybook/src/storybook.test.ts
@@ -2,7 +2,6 @@ import {
checkFilesExist,
cleanupProject,
killPorts,
- newProject,
runCLI,
runCommandUntil,
tmpProjPath,
@@ -10,19 +9,30 @@ import {
updateJson,
getPackageManagerCommand,
runCommand,
+ getSelectedPackageManager,
+ runCreateWorkspace,
} from '@nrwl/e2e/utils';
import { writeFileSync } from 'fs';
-describe('Storybook schematics', () => {
+describe('Storybook generators for non-angular projects', () => {
const previousPM = process.env.SELECTED_PM;
let reactStorybookLib: string;
- let proj: string;
+ const packageManager = getSelectedPackageManager() || 'yarn';
+ const proj = uniq('proj');
+ const appName = uniq('app');
beforeAll(() => {
process.env.SELECTED_PM = 'yarn';
- proj = newProject();
+ runCreateWorkspace(proj, {
+ preset: 'react-monorepo',
+ appName,
+ style: 'css',
+ packageManager,
+ bundler: 'webpack',
+ });
+
reactStorybookLib = uniq('test-ui-lib-react');
runCLI(`generate @nrwl/react:lib ${reactStorybookLib} --no-interactive`);
@@ -61,7 +71,12 @@ describe('Storybook schematics', () => {
}, 1000000);
});
- describe('build storybook', () => {
+ // TODO: Re-enable this test when Nx uses only Storybook 7 (Nx 16)
+ // This fails for Node 18 because Storybook 6.5 uses webpack even in non-webpack projects
+ // https://github.com/storybookjs/builder-vite/issues/414#issuecomment-1287536049
+ // https://github.com/storybookjs/storybook/issues/20209
+ // Error: error:0308010C:digital envelope routines::unsupported
+ xdescribe('build storybook', () => {
it('should build and lint a React based storybook', () => {
// build
runCLI(`run ${reactStorybookLib}:build-storybook --verbose`);
@@ -72,27 +87,23 @@ describe('Storybook schematics', () => {
expect(output).toContain('All files pass linting.');
}, 1000000);
- it('should build a React based storybook that references another lib', () => {
+ // I am not sure how much sense this test makes - Maybe it's just adding noise
+ xit('should build a React based storybook that references another lib', () => {
const anotherReactLib = uniq('test-another-lib-react');
runCLI(`generate @nrwl/react:lib ${anotherReactLib} --no-interactive`);
// create a React component we can reference
writeFileSync(
tmpProjPath(`libs/${anotherReactLib}/src/lib/mytestcmp.tsx`),
`
- import React from 'react';
-
- /* eslint-disable-next-line */
- export interface MyTestCmpProps {}
-
- export const MyTestCmp = (props: MyTestCmpProps) => {
- return (
-
-
Welcome to test cmp!
-
- );
- };
-
- export default MyTestCmp;
+ export function MyTestCmp() {
+ return (
+
+
Welcome to OtherLib!
+
+ );
+ }
+
+ export default MyTestCmp;
`
);
// update index.ts and export it
@@ -109,21 +120,19 @@ describe('Storybook schematics', () => {
`libs/${reactStorybookLib}/src/lib/myteststory.stories.tsx`
),
`
- import React from 'react';
-
- import { MyTestCmp, MyTestCmpProps } from '@${proj}/${anotherReactLib}';
+ import type { Meta } from '@storybook/react';
+ import { MyTestCmp } from '@${proj}/${anotherReactLib}';
- export default {
+ const Story: Meta = {
component: MyTestCmp,
title: 'MyTestCmp',
};
+ export default Story;
- export const primary = () => {
- /* eslint-disable-next-line */
- const props: MyTestCmpProps = {};
-
- return ;
+ export const Primary = {
+ args: {},
};
+
`
);