From 79884774f4aeaeaf894873dae03210ca45409786 Mon Sep 17 00:00:00 2001 From: Katerina Skroumpelou Date: Thu, 16 Mar 2023 19:22:49 +0200 Subject: [PATCH] chore(storybook): change pm and disable --- .../src/storybook-angular.test.ts | 32 +++++-------------- e2e/storybook/src/storybook.test.ts | 14 ++++---- 2 files changed, 15 insertions(+), 31 deletions(-) diff --git a/e2e/storybook-angular/src/storybook-angular.test.ts b/e2e/storybook-angular/src/storybook-angular.test.ts index 9d81f21cc2e8e..a634050e232b5 100644 --- a/e2e/storybook-angular/src/storybook-angular.test.ts +++ b/e2e/storybook-angular/src/storybook-angular.test.ts @@ -11,16 +11,17 @@ import { runCypressTests, tmpProjPath, uniq, - updateJson, } from '@nrwl/e2e/utils'; import { writeFileSync } from 'fs'; describe('Storybook for Angular', () => { + const previousPM = process.env.SELECTED_PM; const packageManager = getSelectedPackageManager() || 'yarn'; const proj = uniq('proj'); const appName = uniq('app'); beforeAll(() => { + process.env.SELECTED_PM = 'yarn'; runCreateWorkspace(proj, { preset: 'angular-monorepo', appName, @@ -29,37 +30,20 @@ describe('Storybook for Angular', () => { }); runCLI( - `generate @nrwl/angular:storybook-configuration ${appName} --generateStories --no-interactive` + `generate @nrwl/angular:storybook-configuration ${appName} --generateStories --storybook7Configuration --no-interactive` ); - // TODO(jack): Overriding enhanced-resolve to 5.10.0 now until the package is fixed. - // See: https://github.com/webpack/enhanced-resolve/issues/362 - updateJson('package.json', (json) => { - if (process.env.SELECTED_PM === 'yarn') { - json['resolutions'] = { - 'enhanced-resolve': '5.10.0', - }; - } else if (process.env.SELECTED_PM === 'npm') { - json['overrides'] = { - 'enhanced-resolve': '5.10.0', - }; - } else { - json['pnpm'] = { - overrides: { - 'enhanced-resolve': '5.10.0', - }, - }; - } - return json; - }); runCommand(getPackageManagerCommand().install); }); - afterAll(() => cleanupProject()); + afterAll(() => { + cleanupProject(); + process.env.SELECTED_PM = previousPM; + }); describe('Storybook builder', () => { it('shoud build storybook', () => { - runCLI(`run ${appName}:build-storybook`); + runCLI(`run ${appName}:build-storybook --verbose`); checkFilesExist(`dist/storybook/${appName}/index.html`); }); }); diff --git a/e2e/storybook/src/storybook.test.ts b/e2e/storybook/src/storybook.test.ts index 51351dfb48fa5..a1863dd48d188 100644 --- a/e2e/storybook/src/storybook.test.ts +++ b/e2e/storybook/src/storybook.test.ts @@ -71,12 +71,7 @@ describe('Storybook generators for non-angular projects', () => { }, 1000000); }); - // 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', () => { + describe('build storybook', () => { it('should build and lint a React based storybook', () => { // build runCLI(`run ${reactStorybookLib}:build-storybook --verbose`); @@ -87,7 +82,12 @@ describe('Storybook generators for non-angular projects', () => { expect(output).toContain('All files pass linting.'); }, 1000000); - // I am not sure how much sense this test makes - Maybe it's just adding noise + // 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 + // Also, 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`);