chromatic-cli
chromatic-cli copied to clipboard
Unable to select story with --only
I’m trying to run chromatic only for a single component, but cannot get the argument to --only
to work.
When run with --list
I get e.g.:
→ Single Case / Top Bar:Main Case Data
→ Single Case / Top Bar:Minimal Data
So I tried running with --only "Single Case / Top Bar:*"
. This causes an error:
✖ Invalid --only Value must be provided in the form 'Path/To/MyStory'. Globbing is supported, for example: 'Pages/**'
Leaving away the spaces around the slash gets around the error, but selects no stories. Maybe the regex for the argument needs to allow spaces?
Did you try --only "Single Case / Top Bar/*"
?
Ok this seems to work indeed.
Not sure how it could have been clear to me :thinking:
Maybe change the format in --list
?
Oh my god, really? This is why I've been struggling to get this to work?
If I see this, I'm going to expect that I need to use a colon as a separator for specific stories.
No wonder that even copying the example didn't work.
Please update the list command, since it is currently giving incorrect information.
Sorry for the confusing messaging. The --list
flag is a very old one and rarely gets used, which is why this was overlooked for a long time.
By the way, could you explain your use case for testing only a single component? We're looking to eventually deprecate the --only
flag, but can only do that if we have a suitable alternative for the use cases that people currently use --only
for.
For me the use case was to quickly check a story when intentionally doing a change and when trying to fix something that is not quite right yet. One instance I remember was that there was some issues that only occured in production mode and another instance was when something looked differently in the chromatic environment vs. local browser view.
I think I read about a (new?) option, which only runs tests based on changed code. So maybe that is the better alternative. Not sure how confident I can be in that though :-) Explicitly selecting seems generally more reliable.
The reason for using --only
vs a full build where
- speed: checking a single story is much faster than checking the whole storybook; especially as the number of stories grows
- cost: chromatic is not exactly cheap. Especially when iterating quickly or trying to fix some kind of mistake, the quota gets used up much faster, than during the regular PR-based workflow.
When I'm trying to fix a problem for a big component, we usually have a lot of stories for it, meaning that --only-changed
will result in for example 20-40 snapshots being taken, compared to only 1 if I'm testing my changes via --only
.
In some cases I need to do this, because some of the problems we encounter only occur in snapshots and not in storybook itself.
Like for example, I have a component that uses DeckGL + ReactMapGL + Mapbox, and the map loads perfectly fine in the chrome snapshot, but doesn't load at all in the firefox snapshot. It's just blank for some reason, even though in storybook we have no issues at all on firefox.
I still have no idea what's causing that, so while I'm testing things like that, I'd very much prefer to save on snapshots by only running a specific story and not everything related to that component.
Hey @bodograumann and @pequeurb! Thanks for your feedback on this. The latest versions of the CLI have deprecated the --only
flag, but we now have new flags, --only-story-names
(similar functionality to --only) & --only-story-files
. You can check out our docs to learn more about the new flags.
https://www.chromatic.com/docs/cli