Skip to content

Commit 5429923

Browse files
authored
Merge pull request #55 from storybookjs/norbert/upgrade-sb-10-esm-only
upgrade to sb10 and esm-only
2 parents 189c05d + bac6053 commit 5429923

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1555
-22106
lines changed

.babelrc.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
module.exports = {
22
presets: [
33
[
4-
"@babel/preset-env",
4+
'@babel/preset-env',
55
{
66
shippedProposals: true,
7-
useBuiltIns: "usage",
8-
corejs: "3",
9-
targets: { node: "14" },
7+
useBuiltIns: 'usage',
8+
corejs: '3',
9+
targets: { node: '14' },
1010
},
1111
],
12-
"@babel/preset-typescript",
13-
"@babel/preset-react",
12+
'@babel/preset-typescript',
13+
'@babel/preset-react',
1414
],
1515
env: {
1616
esm: {
1717
presets: [
1818
[
19-
"@babel/preset-env",
19+
'@babel/preset-env',
2020
{
2121
shippedProposals: true,
22-
useBuiltIns: "usage",
23-
corejs: "3",
22+
useBuiltIns: 'usage',
23+
corejs: '3',
2424
modules: false,
25-
targets: { chrome: "100" },
25+
targets: { chrome: '100' },
2626
},
2727
],
2828
],

.github/workflows/release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ jobs:
88
if: "!contains(github.event.head_commit.message, 'ci skip') && !contains(github.event.head_commit.message, 'skip ci')"
99
steps:
1010
- uses: actions/checkout@v3
11-
11+
1212
- name: Enable Corepack
1313
run: corepack enable
14-
14+
1515
- name: Prepare repository
1616
run: git fetch --unshallow --tags
1717

@@ -26,4 +26,4 @@ jobs:
2626
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2727
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
2828
run: |
29-
yarn release
29+
yarn release

.github/workflows/test.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,18 @@ jobs:
77
runs-on: ubuntu-latest
88
steps:
99
- uses: actions/checkout@v4
10-
10+
1111
- name: Enable Corepack
1212
run: corepack enable
1313

1414
- name: Setup Node.js
1515
uses: actions/setup-node@v4
1616

17+
- name: Install dependencies
18+
run: yarn install
19+
1720
- name: Build coverage addon
18-
run: |
19-
yarn install
21+
run: |
2022
yarn build
2123
2224
- name: Run tests in webpack example
@@ -25,11 +27,14 @@ jobs:
2527
npx playwright install --with-deps
2628
yarn test-storybook:ci-coverage
2729
working-directory: examples/webpack5
30+
env:
31+
YARN_ENABLE_IMMUTABLE_INSTALLS: false
2832

2933
- name: Run tests in vite example
3034
run: |
3135
yarn install
3236
npx playwright install --with-deps
3337
yarn test-storybook:ci-coverage
3438
working-directory: examples/vite
35-
39+
env:
40+
YARN_ENABLE_IMMUTABLE_INSTALLS: false

.prettierignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

.prettierrc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
1-
{}
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "es5",
4+
"printWidth": 120,
5+
"tabWidth": 2
6+
}

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"typescript.tsdk": "node_modules/typescript/lib"
3+
}

README.md

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,21 @@
22

33
Tools to support code coverage in Storybook and the [Storybook test runner](https://github.com/storybookjs/test-runner). It supports Storybook projects that use **Webpack5** or **Vite**.
44

5+
> [!WARNING]
6+
> If you're using Storybook in a Vite-based project, you might want to use [Storybook's Vitest integration](https://storybook.js.org/docs/writing-tests/integrations/vitest-addon?ref=test-runner-migration) instead. It's faster, provides code coverage out of the box (so you don't need this addon anymore), and integrates well with all Storybook's latest features.
7+
8+
## Requirements
9+
10+
- Storybook@>=10.0.0
11+
12+
### Version compatibility
13+
14+
| Addon coverage version | Storybook version |
15+
| ---------------------- | ----------------- |
16+
| ^3.0.0 | ^10.0.0 |
17+
| ^2.0.0 | ^9.0.0 |
18+
| ^2.0.0 | ^8.0.0 |
19+
520
### Installation
621

722
Install this addon by adding the `@storybook/addon-coverage` dependency:
@@ -14,7 +29,7 @@ And by registering it in your `.storybook/main.js`:
1429

1530
```js
1631
export default {
17-
addons: ["@storybook/addon-coverage"],
32+
addons: ['@storybook/addon-coverage'],
1833
};
1934
```
2035

@@ -26,10 +41,10 @@ This addon instruments your code by using a custom wrapper around [istanbul-lib-
2641
export default {
2742
addons: [
2843
{
29-
name: "@storybook/addon-coverage",
44+
name: '@storybook/addon-coverage',
3045
options: {
3146
istanbul: {
32-
include: ["**/stories/**"],
47+
include: ['**/stories/**'],
3348
},
3449
},
3550
},
@@ -59,7 +74,7 @@ export default {
5974
> If you're using TypeScript, you can import the type for the options like so:
6075
>
6176
> ```ts
62-
> import type { AddonOptionsWebpack } from "@storybook/addon-coverage";
77+
> import type { AddonOptionsWebpack } from '@storybook/addon-coverage';
6378
> ```
6479
6580
**The available options if your project uses Vite are as follows:**
@@ -80,10 +95,9 @@ export default {
8095
> If you're using TypeScript, you can import the type for the options like so:
8196
>
8297
> ```ts
83-
> import type { AddonOptionsVite } from "@storybook/addon-coverage";
98+
> import type { AddonOptionsVite } from '@storybook/addon-coverage';
8499
> ```
85100
86-
87101
## Troubleshooting
88102
89103
### The coverage addon doesn't support optimized builds
@@ -99,13 +113,10 @@ export default {
99113
// Your Storybook configuration goes here
100114
build: {
101115
test: {
102-
disabledAddons: [
103-
'@storybook/addon-docs',
104-
'@storybook/addon-essentials/docs',
105-
],
116+
disabledAddons: ['@storybook/addon-docs', '@storybook/addon-essentials/docs'],
106117
},
107118
},
108-
}
119+
};
109120
```
110121
111122
### Development scripts

examples/vite/.storybook/main.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
export default {
2-
stories: ["../src/**/*.stories.@(js|jsx|ts|tsx)"],
2+
stories: ['../src/**/*.stories.@(js|jsx|ts|tsx)'],
33

4-
addons: [
5-
"@storybook/addon-essentials",
6-
"@storybook/addon-interactions",
7-
"@storybook/addon-coverage",
8-
],
4+
addons: ['@storybook/addon-coverage'],
95

106
framework: {
11-
name: "@storybook/react-vite",
7+
name: '@storybook/react-vite',
128
options: {},
139
},
1410
};
Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
export const decorators = [(StoryFn) => {
2-
console.log(globalThis.__coverage__)
3-
return StoryFn()
4-
}]
1+
export const decorators = [
2+
(StoryFn) => {
3+
console.log(globalThis.__coverage__);
4+
return StoryFn();
5+
},
6+
];
57

68
export const parameters = {
79
controls: {
@@ -10,4 +12,4 @@ export const parameters = {
1012
date: /Date$/,
1113
},
1214
},
13-
}
15+
};

examples/vite/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8" />

0 commit comments

Comments
 (0)