Skip to content

Commit

Permalink
Merge pull request #890 from chromaui/889-add-missing-skip-config-option
Browse files Browse the repository at this point in the history
Add missing `skip` option to configuration schema
  • Loading branch information
ghengeveld authored Jan 16, 2024
2 parents 7ae7234 + 09cdc38 commit 1e760f3
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 2 deletions.
92 changes: 90 additions & 2 deletions node-src/lib/getConfiguration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,97 @@ beforeEach(() => {
});

it('reads configuration successfully', async () => {
mockedReadFile.mockReturnValue(JSON.stringify({ projectToken: 'json-file-token' }));
mockedReadFile.mockReturnValue(
JSON.stringify({
projectId: 'project-id',
projectToken: 'project-token',

onlyChanged: 'only-changed',
onlyStoryFiles: ['only-story-files'],
onlyStoryNames: ['only-story-names'],
untraced: ['untraced'],
externals: ['externals'],
debug: true,
diagnosticFile: 'diagnostic-file',
fileHashing: true,
junitReport: 'junit-report',
zip: true,
autoAcceptChanges: 'auto-accept-changes',
exitZeroOnChanges: 'exit-zero-on-changes',
exitOnceUploaded: 'exit-once-uploaded',
ignoreLastBuildOnBranch: 'ignore-last-build-on-branch',

buildScriptName: 'build-script-name',
outputDir: 'output-dir',
skip: 'skip',

storybookBuildDir: 'storybook-build-dir',
storybookBaseDir: 'storybook-base-dir',
storybookConfigDir: 'storybook-config-dir',
storybookLogFile: 'storybook-log-file',
logFile: 'log-file',
uploadMetadata: true,
})
);

expect(await getConfiguration()).toEqual({
projectId: 'project-id',
projectToken: 'project-token',

onlyChanged: 'only-changed',
onlyStoryFiles: ['only-story-files'],
onlyStoryNames: ['only-story-names'],
untraced: ['untraced'],
externals: ['externals'],
debug: true,
diagnosticFile: 'diagnostic-file',
fileHashing: true,
junitReport: 'junit-report',
zip: true,
autoAcceptChanges: 'auto-accept-changes',
exitZeroOnChanges: 'exit-zero-on-changes',
exitOnceUploaded: 'exit-once-uploaded',
ignoreLastBuildOnBranch: 'ignore-last-build-on-branch',

buildScriptName: 'build-script-name',
outputDir: 'output-dir',
skip: 'skip',

storybookBuildDir: 'storybook-build-dir',
storybookBaseDir: 'storybook-base-dir',
storybookConfigDir: 'storybook-config-dir',
storybookLogFile: 'storybook-log-file',
logFile: 'log-file',
uploadMetadata: true,
});
});

expect(await getConfiguration()).toEqual({ projectToken: 'json-file-token' });
it('handles other side of union options', async () => {
mockedReadFile.mockReturnValue(
JSON.stringify({
onlyChanged: true,
diagnosticFile: true,
junitReport: true,
autoAcceptChanges: true,
exitZeroOnChanges: true,
exitOnceUploaded: true,
skip: true,
storybookLogFile: true,
logFile: true,
})
);

expect(await getConfiguration()).toEqual({
onlyChanged: true,
diagnosticFile: true,
junitReport: true,
autoAcceptChanges: true,
exitZeroOnChanges: true,
exitOnceUploaded: true,
skip: true,
storybookLogFile: true,
logFile: true,
});
});

it('reads from chromatic.config.json by default', async () => {
Expand Down
1 change: 1 addition & 0 deletions node-src/lib/getConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const configurationSchema = z

buildScriptName: z.string(),
outputDir: z.string(),
skip: z.union([z.string(), z.boolean()]),

storybookBuildDir: z.string(),
storybookBaseDir: z.string(),
Expand Down

0 comments on commit 1e760f3

Please sign in to comment.