Skip to content

Commit

Permalink
do not prompt to install chromatic script during E2E builds
Browse files Browse the repository at this point in the history
  • Loading branch information
tevanoff committed Mar 6, 2024
1 parent cfeec9a commit 0440f7a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 9 additions & 0 deletions node-src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { DNSResolveAgent } from './io/getDNSResolveAgent';
import getEnv from './lib/getEnv';
import parseArgs from './lib/parseArgs';
import TestLogger from './lib/testLogger';
import * as checkPackageJson from './lib/checkPackageJson';
import { uploadFiles } from './lib/uploadFiles';
import { writeChromaticDiagnostics } from './lib/writeChromaticDiagnostics';
import { Context } from './types';
Expand Down Expand Up @@ -712,6 +713,14 @@ it('prompts you to add a script to your package.json', async () => {
expect(confirm).toHaveBeenCalled();
});

it('does not propmpt you to add a script to your package.json for E2E builds', async () => {
const ctx = getContext(['--project-token=asdf1234', '--playwright']);
await runAll(ctx);
const spy = vi.spyOn(checkPackageJson, 'default');
expect(spy).not.toHaveBeenCalled();
expect(confirm).not.toHaveBeenCalled();
});

it('ctx should be JSON serializable', async () => {
const ctx = getContext(['--project-token=asdf1234']);
expect(() => writeChromaticDiagnostics(ctx)).not.toThrow();
Expand Down
3 changes: 2 additions & 1 deletion node-src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import noPackageJson from './ui/messages/errors/noPackageJson';
import runtimeError from './ui/messages/errors/runtimeError';
import taskError from './ui/messages/errors/taskError';
import intro from './ui/messages/info/intro';
import { isE2EBuild } from './lib/e2e';

/**
Make keys of `T` outside of `R` optional.
Expand Down Expand Up @@ -176,7 +177,7 @@ export async function runAll(ctx: InitialContext) {
// Run these in parallel; neither should ever reject
await Promise.all([runBuild(ctx), checkForUpdates(ctx)]).catch(onError);

if ([0, 1].includes(ctx.exitCode)) {
if (!isE2EBuild(ctx.options) && [0, 1].includes(ctx.exitCode)) {
await checkPackageJson(ctx);
}

Expand Down

0 comments on commit 0440f7a

Please sign in to comment.