Skip to content

Commit bebceba

Browse files
committed
test(spec): assert the deleted exports before the call order, so a regression names the harm
Claude-Session: https://claude.ai/code/session_01UDXER3sdqfeVYpEWZs5mZx Co-authored-by: Claude <noreply@anthropic.com>
1 parent 04b07de commit bebceba

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

‎packages/spec/scripts/check-generated-fix-rebuild.pin.test.ts‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -215,13 +215,14 @@ describe('check:generated --fix rebuilds what it writes from (#19086)', () => {
215215

216216
const code = checkGenerated(['--fix'], SCRIPTS, w.io);
217217

218-
expect(w.calls[0]).toBe('build'); // rebuilt BEFORE anything
219-
expect(w.calls.indexOf('build')).toBeLessThan(
220-
w.calls.indexOf('check:api-surface') === -1 ? Infinity : w.calls.indexOf('check:api-surface'),
221-
);
222-
expect(readBaseline(w.root)['meta-spelling']).toHaveLength(8);
218+
// THE HARM, asserted first so a regression names the deleted exports rather
219+
// than the missing call: without the forced build this baseline loses them.
223220
expect(readBaseline(w.root)['meta-spelling']).toContain('singularToPlural');
224221
expect(readBaseline(w.root)['meta-spelling']).toContain('unrecognisedMetaTypeRefusal');
222+
expect(readBaseline(w.root)['meta-spelling']).toHaveLength(8);
223+
// THE MECHANISM: the build ran first, and every gate saw the dist it emitted.
224+
expect(w.calls[0]).toBe('build');
225+
expect(w.calls.indexOf('build')).toBeLessThan(w.calls.indexOf('check:api-surface'));
225226
expect(code).toBe(0);
226227
rmSync(w.root, { recursive: true, force: true });
227228
});
@@ -251,10 +252,13 @@ describe('check:generated --fix rebuilds what it writes from (#19086)', () => {
251252

252253
const code = checkGenerated(['--fix'], SCRIPTS, w.io);
253254

254-
expect(w.calls[0]).toBe('build');
255-
expect(readBaseline(w.root).root).toHaveLength(full.length);
255+
// THE HARM first, for the same reason as B1 above.
256256
expect(readBaseline(w.root).root).toContain('chunkExport3a');
257257
expect(readBaseline(w.root).root).toContain('chunkExport17b');
258+
expect(readBaseline(w.root).root).toHaveLength(full.length);
259+
// THE MECHANISM.
260+
expect(w.calls[0]).toBe('build');
261+
expect(w.calls.indexOf('build')).toBeLessThan(w.calls.indexOf('check:api-surface'));
258262
expect(code).toBe(0);
259263
rmSync(w.root, { recursive: true, force: true });
260264
});

0 commit comments

Comments
 (0)