new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Storybook · all subjects

contributing/testing

8 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

Running tests in Storybook development

After successfully running the first sandbox, verify the setup by running the test suite with `yarn test` before making any code changes.

Adding stories for testing contributions

When working on essential features, check the addon's `template/stories` directory for existing stories. If modifying something related to a specific renderer (React, Vue 3, etc.), add stories to the similar `template/stories` directory in that renderer's location.

Unit test naming convention in Storybook

Use the following naming convention for unit tests: place both `[filename].ts` and `[filename].test.ts` in the same parent folder. Unit tests ensure Storybook doesn't break accidentally and should be included for code that can regress in non-obvious ways.

End-to-end testing with Playwright in Storybook

Storybook's monorepo uses end-to-end testing with Playwright during CI. To run an e2e test against a sandbox, use the task: `yarn task --task e2e-tests --template=react-vite/default-ts --start-from=auto`. To debug issues, pass the `DEBUG=1` environment variable to run Playwright in watch mode: `DEBUG=1 yarn task --task e2e-tests --template=react-vite/default-ts --start-from=auto`.

Running tests before pull request submission

Before submitting a contribution, run the test suite one last time with `yarn test` to prevent last-minute bugs and ensure faster merging. If snapshot tests fail during the run, re-run with the `-u` flag to update them. Failing to run tests will result in maintainers marking the pull request with the **Work in Progress** label.

Storybook testing framework

Storybook relies on Vitest as part of its testing suite.

Create React App coverage tests: exclude stories with Jest

To run coverage tests with Create React App and exclude stories, use: npm test -- --coverage --collectCoverageFrom='["src/**/*.{js,jsx}","!src/**/stories/*"]'. Note: Yarn users need to adjust the command accordingly.

Storybook test runner compatibility with Jest 28

There is an issue with Storybook's test runner and Jest version 28 that prevents it from running effectively. As a workaround, downgrade Jest to version 27 to use the test runner.

Give your agent this brain