Skip to content

Commit 2c108eb

Browse files
committed
Skip notify service if there are no tests
1 parent 409616d commit 2c108eb

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

node-src/tasks/snapshot.test.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,31 @@ describe('takeSnapshots', () => {
191191
features: {},
192192
reportToken: 'report-token',
193193
id: 'build-123',
194+
actualTestCount: 0,
195+
};
196+
const ctx = {
197+
...createBaseTestContext(),
198+
build,
199+
} as any;
200+
201+
mockWaitForBuildToComplete.mockResolvedValue();
202+
ctx.client.runQuery.mockReturnValueOnce({
203+
app: { build: { changeCount: 0, status: 'PASSED', completedAt: 1 } },
204+
});
205+
206+
await takeSnapshots(ctx, {} as any);
207+
208+
expect(mockWaitForBuildToComplete).not.toHaveBeenCalled();
209+
});
210+
211+
it('does not call waitForBuildToComplete if there are no tests', async () => {
212+
const build = {
213+
app: { repository: { provider: 'github' } },
214+
number: 1,
215+
features: {},
216+
reportToken: 'report-token',
217+
id: 'build-123',
218+
actualTestCount: 1,
194219
};
195220
const ctx = {
196221
...createBaseTestContext(),
@@ -222,6 +247,7 @@ describe('takeSnapshots', () => {
222247
features: {},
223248
reportToken: 'report-token',
224249
id: 'build-123',
250+
actualTestCount: 1,
225251
};
226252
const ctx = {
227253
...createBaseTestContext(),
@@ -250,6 +276,7 @@ describe('takeSnapshots', () => {
250276
features: {},
251277
reportToken: 'report-token',
252278
id: 'build-123',
279+
actualTestCount: 1,
253280
};
254281
const ctx = {
255282
...createBaseTestContext(),
@@ -283,6 +310,7 @@ describe('takeSnapshots', () => {
283310
features: {},
284311
reportToken: 'report-token',
285312
id: 'build-123',
313+
actualTestCount: 1,
286314
};
287315
const ctx = {
288316
...createBaseTestContext(),
@@ -316,6 +344,7 @@ describe('takeSnapshots', () => {
316344
features: {},
317345
reportToken: 'report-token',
318346
id: 'build-123',
347+
actualTestCount: 1,
319348
};
320349
const ctx = {
321350
...createBaseTestContext(),
@@ -344,6 +373,7 @@ describe('takeSnapshots', () => {
344373
features: {},
345374
reportToken: 'report-token',
346375
id: 'build-123',
376+
actualTestCount: 1,
347377
};
348378
const ctx = {
349379
...createBaseTestContext(),

node-src/tasks/snapshot.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,10 @@ export const takeSnapshots = async (ctx: Context, task: Task) => {
113113
await delay(ctx.env.CHROMATIC_POLL_INTERVAL);
114114
return getCompletedBuild();
115115
};
116-
await waitForBuildToCompleteAndHandleErrors(ctx, uiStateUpdater, reportToken);
116+
117+
if (actualTestCount > 0) {
118+
await waitForBuildToCompleteAndHandleErrors(ctx, uiStateUpdater, reportToken);
119+
}
117120

118121
const build = await getCompletedBuild();
119122

0 commit comments

Comments
 (0)