Skip to content

Commit

Permalink
chore(storybook): change pm and disable
Browse files Browse the repository at this point in the history
  • Loading branch information
mandarini committed Mar 16, 2023
1 parent 6704148 commit 7988477
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 31 deletions.
32 changes: 8 additions & 24 deletions e2e/storybook-angular/src/storybook-angular.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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`);
});
});
Expand Down
14 changes: 7 additions & 7 deletions e2e/storybook/src/storybook.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
Expand All @@ -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`);
Expand Down

0 comments on commit 7988477

Please sign in to comment.