Skip to content

Commit b2cee44

Browse files
authored
Merge pull request storybookjs#458 from storybookjs/release/0.18.0
Release 0.18.0
2 parents b4931f8 + 160e84b commit b2cee44

File tree

8 files changed

+147
-130
lines changed

8 files changed

+147
-130
lines changed

.github/ISSUE_TEMPLATE/bug-report-🐞.md

Lines changed: 0 additions & 30 deletions
This file was deleted.

.github/ISSUE_TEMPLATE/bug_report.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Bug report 🐞
2+
description: >-
3+
Something is broken and you have a reliable reproduction? Let us know here.
4+
For questions, please use "Question" below.
5+
title: '[Bug]: '
6+
labels:
7+
- needs triage
8+
- bug
9+
body:
10+
- type: textarea
11+
id: description
12+
attributes:
13+
label: Describe the bug
14+
description: A clear and concise description of what the bug is
15+
validations:
16+
required: true
17+
- type: textarea
18+
id: reproduce
19+
attributes:
20+
label: To Reproduce
21+
description: >-
22+
Due to the high volume of reports we receive, we can only prioritize bug reports that include a clear reproduction of the problem. Please use [storybook.new](https://storybook.new) to create one, and consult our [documentation](https://storybook.js.org/docs/react/contribute/how-to-reproduce) for guidance. Thank you for your understanding!
23+
placeholder: >-
24+
Please provide a link to your reproduction here. If creating a reproduction really isn't feasible, let us know and be sure to include as much detail as you can to help us understand the issue.
25+
validations:
26+
required: true
27+
- type: textarea
28+
id: system
29+
attributes:
30+
label: System
31+
description: Please paste the results of `npx storybook@latest info` here.
32+
render: bash
33+
validations:
34+
required: true
35+
- type: textarea
36+
id: context
37+
attributes:
38+
label: Additional context
39+
description: Add any other context about the problem here.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Feature request 🚀
2+
description: >-
3+
Suggest a feature idea for this project.
4+
title: '[Feature request]: '
5+
labels:
6+
- needs triage
7+
- feature request
8+
body:
9+
- type: textarea
10+
id: problem
11+
attributes:
12+
label: Is your feature request related to a problem? Please describe.
13+
description: >-
14+
A clear and concise description of the problem. E.g. I'm always
15+
frustrated when [...]
16+
- type: textarea
17+
id: describe
18+
attributes:
19+
label: Describe the solution you'd like
20+
description: What would you like to see added to Storybook to solve problem?
21+
validations:
22+
required: true
23+
- type: textarea
24+
id: alternatives
25+
attributes:
26+
label: Describe alternatives you've considered
27+
description: Any alternative solutions or features you've considered.
28+
- type: dropdown
29+
id: help
30+
attributes:
31+
label: Are you able to assist to bring the feature to reality?
32+
options:
33+
- 'no'
34+
- yes, I can
35+
validations:
36+
required: true
37+
- type: textarea
38+
id: context
39+
attributes:
40+
label: Additional context
41+
description: Add any other context or screenshots about the feature request here.

README.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ Usage: test-storybook [options]
156156
| `--url` | Define the URL to run tests in. Useful for custom Storybook URLs <br/>`test-storybook --url http://the-storybook-url-here.com` |
157157
| `--browsers` | Define browsers to run tests in. One or multiple of: chromium, firefox, webkit <br/>`test-storybook --browsers firefox chromium` |
158158
| `--maxWorkers [amount]` | Specifies the maximum number of workers the worker-pool will spawn for running tests <br/>`test-storybook --maxWorkers=2` |
159+
| `--testTimeout [number]` | This option sets the default timeouts of test cases <br/>`test-storybook --testTimeout=15_000` |
159160
| `--no-cache` | Disable the cache <br/>`test-storybook --no-cache` |
160161
| `--clearCache` | Deletes the Jest cache directory and then exits without running tests <br/>`test-storybook --clearCache` |
161162
| `--verbose` | Display individual test results with the test suite hierarchy <br/>`test-storybook --verbose` |
@@ -173,7 +174,7 @@ Usage: test-storybook [options]
173174

174175
## Ejecting configuration
175176

176-
The test runner is based on [Jest](https://jestjs.io/) and will accept most of the [CLI options](https://jestjs.io/docs/cli) that Jest does, like `--watch`, `--watchAll`, `--maxWorkers`, etc. It works out of the box, but if you want better control over its configuration, you can eject its configuration by running `test-storybook --eject` to create a local `test-runner-jest.config.js` file in the root folder of your project. This file will be used by the test runner.
177+
The test runner is based on [Jest](https://jestjs.io/) and will accept most of the [CLI options](https://jestjs.io/docs/cli) that Jest does, like `--watch`, `--watchAll`, `--maxWorkers`, `--testTimeout`, etc. It works out of the box, but if you want better control over its configuration, you can eject its configuration by running `test-storybook --eject` to create a local `test-runner-jest.config.js` file in the root folder of your project. This file will be used by the test runner.
177178

178179
> **Note**
179180
> The `test-runner-jest.config.js` file can be placed inside of your Storybook config dir as well. If you pass the `--config-dir` option, the test-runner will look for the config file there as well.
@@ -350,10 +351,10 @@ jobs:
350351
runs-on: ubuntu-latest
351352
if: github.event.deployment_status.state == 'success'
352353
steps:
353-
- uses: actions/checkout@v3
354-
- uses: actions/setup-node@v2
354+
- uses: actions/checkout@v4
355+
- uses: actions/setup-node@v4
355356
with:
356-
node-version: '14.x'
357+
node-version: '18.x'
357358
- name: Install dependencies
358359
run: yarn
359360
- name: Run Storybook tests
@@ -385,10 +386,10 @@ jobs:
385386
timeout-minutes: 60
386387
runs-on: ubuntu-latest
387388
steps:
388-
- uses: actions/checkout@v3
389-
- uses: actions/setup-node@v2
389+
- uses: actions/checkout@v4
390+
- uses: actions/setup-node@v4
390391
with:
391-
node-version: '14.x'
392+
node-version: '18.x'
392393
- name: Install dependencies
393394
run: yarn
394395
- name: Run Storybook tests
@@ -1018,6 +1019,12 @@ In either way, to fix it you should limit the amount of workers that run in para
10181019
}
10191020
```
10201021
1022+
Another option is trying to increase the test timeout by passing the [--testTimeout](https://jestjs.io/docs/cli#--testtimeoutnumber) option to your command (adding `--testTimeout=60_000` will increase test timeouts to 1 minute):
1023+
1024+
```json
1025+
"test-storybook:ci": "concurrently -k -s first -n \"SB,TEST\" -c \"magenta,blue\" \"yarn build-storybook --quiet && npx http-server storybook-static --port 6006 --silent\" \"wait-on tcp:6006 && yarn test-storybook --maxWorkers=2 --testTimeout=60_000\""
1026+
```
1027+
10211028
#### The test runner reports "No tests found" running on a Windows CI
10221029
10231030
There is currently a [bug](https://github.com/facebook/jest/issues/8536) in Jest which means tests cannot be on a separate drive than the project. To work around this you will need to set the `TEMP` environment variable to a temporary folder on the same drive as your project. Here's what that would look like on GitHub Actions:

package.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,11 @@
7171
"jest-runner": "^29.6.4",
7272
"jest-serializer-html": "^7.1.0",
7373
"jest-watch-typeahead": "^2.0.0",
74+
"nyc": "^15.1.0",
7475
"playwright": "^1.14.0"
7576
},
7677
"devDependencies": {
77-
"@auto-it/released": "^11.1.1",
78+
"@auto-it/released": "^11.1.6",
7879
"@babel/cli": "^7.12.1",
7980
"@babel/preset-env": "^7.19.4",
8081
"@babel/preset-react": "^7.18.6",
@@ -89,14 +90,13 @@
8990
"@types/node": "^16.4.1",
9091
"@types/node-fetch": "^2.6.11",
9192
"@vitejs/plugin-react": "^4.0.3",
92-
"auto": "^11.1.1",
93+
"auto": "^11.1.6",
9394
"babel-jest": "^29.0.0",
9495
"babel-loader": "^8.1.0",
9596
"babel-plugin-istanbul": "^6.1.1",
9697
"can-bind-to-host": "^1.1.1",
9798
"commander": "^9.0.0",
9899
"concurrently": "^7.0.0",
99-
"detect-package-manager": "^3.0.1",
100100
"glob": "^10.2.2",
101101
"husky": "^8.0.0",
102102
"jest-image-snapshot": "^6.2.0",
@@ -107,8 +107,6 @@
107107
"react": "^17.0.1",
108108
"react-dom": "^17.0.1",
109109
"read-pkg-up": "^7.0.1",
110-
"rimraf": "^3.0.2",
111-
"semver": "^7.5.4",
112110
"storybook": "^8.0.0",
113111
"tempy": "^1.0.1",
114112
"ts-dedent": "^2.0.0",

src/test-storybook.ts

Lines changed: 8 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import canBindToHost from 'can-bind-to-host';
77
import dedent from 'ts-dedent';
88
import path from 'path';
99
import tempy from 'tempy';
10-
import semver from 'semver';
11-
import { detect as detectPackageManager } from 'detect-package-manager';
1210

1311
import { JestOptions, getCliOptions } from './util/getCliOptions';
1412
import { getStorybookMetadata } from './util/getStorybookMetadata';
@@ -48,38 +46,11 @@ const cleanup = () => {
4846
}
4947
};
5048

51-
// Inspired by github.com/nrwl/nx/blob/1975181c200eb288221c8beb94e268fe9659cc26/packages/nx/src/utils/package-manager.ts#L48-106
52-
async function getExecutorCommand() {
53-
const commands = {
54-
npm: () => 'npx',
55-
pnpm: () => {
56-
const pnpmVersion = getPackageManagerVersion('pnpm');
57-
const useExec = semver.gte(pnpmVersion, '6.13.0');
58-
59-
return useExec ? 'pnpm exec' : 'pnpx';
60-
},
61-
yarn: () => {
62-
const yarnVersion = getPackageManagerVersion('yarn');
63-
const useBerry = semver.gte(yarnVersion, '2.0.0');
64-
return useBerry ? 'yarn exec' : 'yarn';
65-
},
66-
};
67-
68-
try {
69-
let packageManager = await detectPackageManager();
70-
if (packageManager === 'bun') {
71-
packageManager = 'npm';
72-
}
73-
74-
return commands[packageManager]();
75-
} catch (err) {
76-
return commands.npm();
77-
}
78-
}
79-
80-
// Copied from https://github.com/nrwl/nx/blob/1975181c200eb288221c8beb94e268fe9659cc26/packages/nx/src/utils/package-manager.ts#L113-L117
81-
function getPackageManagerVersion(packageManager: 'npm' | 'pnpm' | 'yarn') {
82-
return execSync(`${packageManager} --version`).toString('utf-8').trim();
49+
function getNycBinPath() {
50+
const nycPath = path.join(require.resolve('nyc/package.json'));
51+
const nycBin = require(nycPath).bin.nyc;
52+
const nycBinFullPath = path.join(path.dirname(nycPath), nycBin);
53+
return nycBinFullPath;
8354
}
8455

8556
async function reportCoverage() {
@@ -107,11 +78,12 @@ async function reportCoverage() {
10778
// --check-coverage if we want to break if coverage reaches certain threshold
10879
// .nycrc will be respected for thresholds etc. https://www.npmjs.com/package/nyc#coverage-thresholds
10980
if (process.env.JEST_SHARD !== 'true') {
110-
const executorCommand = await getExecutorCommand();
81+
const nycBinFullPath = getNycBinPath();
11182
execSync(
112-
`${executorCommand} nyc report --reporter=text -t ${coverageFolder} --report-dir ${coverageFolder}`,
83+
`${nycBinFullPath} report --reporter=text --reporter=lcov -t ${coverageFolder} --report-dir ${coverageFolder}`,
11384
{
11485
stdio: 'inherit',
86+
cwd: process.cwd(),
11587
}
11688
);
11789
}

src/util/getParsedCliOptions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export const getParsedCliOptions = (): ParsedCliOptions => {
3939
'--maxWorkers <amount>',
4040
'Specifies the maximum number of workers the worker-pool will spawn for running tests'
4141
)
42+
.option('--testTimeout <number>', 'This option sets the default timeouts of test cases')
4243
.option('--no-cache', 'Disable the cache')
4344
.option('--clearCache', 'Deletes the Jest cache directory and then exits without running tests')
4445
.option('--verbose', 'Display individual test results with the test suite hierarchy')

0 commit comments

Comments
 (0)