File Conventions
Three options:
- End fixture file names with
.fixture.{js,jsx,ts,tsx,md,mdx}
. - Put fixture files inside
__fixtures__
directories. - Use
fixture.{js,jsx,ts,tsx,md,mdx}
as the name.
The file paths of your fixture files (relative to your project root) are used to create a tree view explorer in the React Cosmos UI.
Examples (one fixture file per component)
MyComponent.fixture.jsx
__fixtures__/MyComponent.jsx
MyComponent/fixture.jsx
- MyComponent
Examples (multiple fixture files per component)
MyComponent/blankState.fixture.jsx
MyComponent/__fixtures__/blankState.jsx
or__fixtures__/MyComponent/blankState.jsx
- blankState
Configuration
You can customize these file conventions in your Cosmos config:
Option | Description | Default |
---|---|---|
fixturesDir | Name for directories that contain fixture files (eg. __fixtures__/example.jsx ). | "__fixtures__" |
fixtureFileSuffix | Suffix for fixture files (eg. example.fixture.jsx ). | "fixture" |
ignore | Patterns for ignoring fixture and decorator files (eg. ["**/dist/**"] ). |