-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use chromatic.config.json
rather than setting options in main.js
#94
Use chromatic.config.json
rather than setting options in main.js
#94
Conversation
AP-3623 Add CLI support for a chromatic.js config file that allows multiple environments and configuration outside of .storybook/
Currently users must configure their chromatic cli inside of storybook configuration and through cli flags. This may be confusing as users might require different settings for local builds vs ci builds. We may be able to improve this by allowing users to define their configurations in a separate, type-safe config file. This should be an additional form of configuration, and allow backwards compatibility for existing setups using cli flags and ci configuration. It may need to allow both approaches to be mixed. Multiple Environments: With the addon-visual-tests having more users run builds outside of CI, configuration for the cli may need to vary based on the environment. Supporting multiple environments, through environment-suffixed names or programatic configuration would help optimize configuration for local builds. Related Slack thread: https://chromaticqa.slack.com/archives/C051TQR6QLC/p1693198584200749 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
In testing, on step 4, when it doesn't have a projectId but does have a projectToken (presumably from existing chromatic config) it removes the projectToken as soon as storybook starts. Is that intentional? It makes sense that we update it after configuration anyways, but wanted to confirm.
@tmeasday I'm still running some tests and share the findings tomorrow morning my time. |
That seems.. odd. Can you explain how I can reproduce that? |
@tmeasday change the chromatic.config.json to only have the projectToken (remove the projectId) and then start Storybook. It changes the file to be an empty object. It looks like the first time it loads the configuration triggers the on change handler from my test |
Fixed it, thanks @weeksling |
@tmeasday so far, this is shaping up nicely; based on the QA instructions you left, it seems that one of the significant issues was already mentioned by @weeksling, and it seems fixed. However, during my testing, I noticed some things that require attention from the CLI pr. Here's a bit of an overview of what I uncovered and the steps taken:
Error: ✖ Build script not found
The CLI didn't find a script called "build-storybook" in your package.json.
Make sure you set the --build-script-name option to the value of the script name that builds your Storybook.
at JZ (/Users/my-user/testing-file-config/node_modules/chromatic/dist/chunk-3ZZOUQMD.js:202:3145)
at H8t (/Users/my-user/testing-file-config/node_modules/chromatic/dist/chunk-3ZZOUQMD.js:1360:1319)
at async Promise.all (index 0)
at async Cgi (/Users/my-user/testing-file-config/node_modules/chromatic/dist/chunk-3ZZOUQMD.js:1396:1226)
at async Object.UWi (/Users/my-user/testing-file-config/node_modules/chromatic/dist/chunk-3ZZOUQMD.js:1396:462)
at async Object.<anonymous> (/Users/my-user/testing-file-config/node_modules/@chromaui/addon-visual-tests/dist/index.js:8:418)
|
Hey @jonniebigodes that's just because I forgot to add |
…upport-for-a-chromaticjs-config-file-that-allows-2
Depends on chromaui/chromatic-cli#814
Now you can only set
configPath
inmain.js
(the location of the configuration, which defaults tochromatic.config.json
).To QA
chromatic.config.json
, unset themain.js
configPath
optionchromatic.config.json
to only having theprojectToken
set (simulating someone who's configured Chromatic already)chromatic.config.json
have invalid JSON, check for meaningful error.configPath
to something different (test.config.json
), check for meaningful error when you start without the file existingtest.config.json
with justprojectToken
📦 Published PR as canary version:
0.0.70--canary.94.0c85a5f.0
✨ Test out this PR locally via:
npm install @chromaui/addon-visual-tests@0.0.70--canary.94.0c85a5f.0 # or yarn add @chromaui/addon-visual-tests@0.0.70--canary.94.0c85a5f.0