diff --git a/node-src/index.test.ts b/node-src/index.test.ts index 555fa27f5..bb06011f1 100644 --- a/node-src/index.test.ts +++ b/node-src/index.test.ts @@ -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'; @@ -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(); diff --git a/node-src/index.ts b/node-src/index.ts index ed62df0c4..54c01e235 100644 --- a/node-src/index.ts +++ b/node-src/index.ts @@ -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. @@ -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); }