Skip to content

Commit

Permalink
docs: re-enable addon-jest with Vite workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
Robbert committed Sep 17, 2023
1 parent 9ecf34b commit dba64dd
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 5 deletions.
16 changes: 15 additions & 1 deletion packages/storybook-react/config/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const config: StorybookConfig = {
'@storybook/addon-a11y',
'storybook-addon-pseudo-states',
'@storybook/preset-scss',
// '@storybook/addon-jest',
'@storybook/addon-jest',
'@etchteam/storybook-addon-status/register',
'storybook-addon-themes',
],
Expand All @@ -28,6 +28,20 @@ const config: StorybookConfig = {
docs: {
autodocs: true,
},
async viteFinal(config) {
// Workaround for `@storybook/addon-jest` with Vite
// https://github.com/storybookjs/storybook/issues/14856#issuecomment-1262333250
if (config.resolve) {
config.resolve = {
...config.resolve,
alias: {
...config.resolve.alias,
path: require.resolve('path-browserify'),
},
};
}
return config;
},
};

export default config;
9 changes: 5 additions & 4 deletions packages/storybook-react/config/preview.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
import { withTests } from '@storybook/addon-jest';
import { Preview } from '@storybook/react';
import results from '@utrecht/component-library-react/dist/.jest-test-results.json';
import { addonStatus } from '@utrecht/storybook-helpers/src/addon-status';
import { addonThemes } from '@utrecht/storybook-helpers/src/addon-themes';
import { addonViewport } from '@utrecht/storybook-helpers/src/addon-viewport';
// import { withTests } from '@storybook/addon-jest';
// import results from '@utrecht/component-library-react/dist/.jest-test-results.json';
import React from 'react';
import '@utrecht/design-tokens/dist/index.css';
import '@utrecht/storybook-helpers/src/storybook-docs.scss';
import '@nl-design-system-unstable/amsterdam-design-tokens/dist/index.css';
import '@nl-design-system-unstable/rotterdam-design-tokens/dist/index.css';
import '@gemeente-denhaag/design-tokens-components/dist/theme/index.css';

console.log(results);
const preview: Preview = {
decorators: [
(Story: any) => <div className="utrecht-document">{Story()}</div>,
// withTests({ results }),
///
withTests({ results }),
],
parameters: {
actions: { argTypesRegex: '^on[A-Z].*' },
Expand Down
14 changes: 14 additions & 0 deletions packages/storybook-vue/config/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,20 @@ const config: StorybookConfig = {
docs: {
autodocs: 'tag',
},
async viteFinal(config) {
// Workaround for `@storybook/addon-jest` with Vite
// https://github.com/storybookjs/storybook/issues/14856#issuecomment-1262333250
if (config.resolve) {
config.resolve = {
...config.resolve,
alias: {
...config.resolve.alias,
path: require.resolve('path-browserify'),
},
};
}
return config;
},
};

export default config;
3 changes: 3 additions & 0 deletions packages/storybook-vue/config/preview.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { withTests } from '@storybook/addon-jest';
import { Preview } from '@storybook/vue3';
import { Document } from '@utrecht/component-library-vue';
import results from '@utrecht/component-library-vue/dist/.jest-test-results.json';
import { addonStatus } from '@utrecht/storybook-helpers/dist/addon-status';
import { addonViewport } from '@utrecht/storybook-helpers/dist/addon-viewport';
import { defineCustomElements } from '@utrecht/web-component-library-stencil/loader';
Expand All @@ -18,6 +20,7 @@ const preview: Preview = {
components: { Document, story },
template: '<Document class="utrecht-theme"><story /></Document>',
}),
withTests({ results }),
],
parameters: {
...addonStatus,
Expand Down

0 comments on commit dba64dd

Please sign in to comment.