Story files tests / Accessibility tests: use a Web Test Runner Plugin instead of individual files #1315
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #731
Fixes #963
Fixes #854
What does this PR do?
src/components/**/*.stories.js
to the list of files to be handled by Web Test Runner. They are then transformed into test files by a plugin.test-stories
plugin that:.stories.test.js
file instead of the story file,.stories.test.js
file when it is requested by the browser and serves it,testStories
helper that will loop over all stories to run tests (at the moment a11y tests to be specific, but later on we'll add visual regression tests in there).getStories
&testStories
helpers into a single file because we never use them separately (testStories
is the only one usinggetStories
so they may as well be in the same file).refactor(stories): disable some accessibility tests and rules
to see how it looks within story files,ResizeObserver
logs + adds export conditions so that we pull prod dependencies instead of dev (this way we test the components in the same conditions as when they are published).How to review?
Tip
It's a good idea to start by checking the updated docs about stories (
Manage accessibility tests
section at the very bottom) in the preview.This way you'll get some overview of the API before diving in the actual implementation of that API.
refactor(tests): remove component test files
but if you do, the only thing to look for is that files removed only contained a11y tests and nothing else.Things to be discussed
There are many things that could be discussed.
Feel free to weigh in about naming / architecture / (de)coupling.
For instance, I didn't try to make the plugin more generic so it could be used by other projects. I focused on our needs and that's it. The idea & principles are very close to what we do in storybook to support markdown with frontmatter.
If needed, we can organize a meeting about this PR to discuss and decide on some specific implementations.