fix(core): improve flaky ci test (#30738)

This PR updates `lerna-smoke-tests.test.ts` test file to improve the
consistency of the snapshots.
The serializer has been updated to reduce flakiness from spacing and
line breaks.
This commit is contained in:
Nicholas Cunningham 2025-04-16 13:08:16 -06:00 committed by GitHub
parent 4b4226d2e0
commit 8b02fd48f7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -13,17 +13,13 @@ import {
expect.addSnapshotSerializer({
serialize(str: string) {
return (
str
// Not all package managers print the package.json path in the output
return str
.replace(/(\r\n|\n)+/g, '\n')
.replace(/\n\s+/g, '\n')
.replace(/\s+\n/g, '\n')
.replace(tmpProjPath(), '')
.replace('/private', '')
.replace('/packages/package-1', '')
// We trim each line to reduce the chances of snapshot flakiness
.split('\n')
.map((r) => r.trim())
.join('\n')
);
.replace('/packages/package-1', '');
},
test(val: string) {
return val != null && typeof val === 'string';
@ -48,12 +44,9 @@ describe('Lerna Smoke Tests', () => {
.replace(/Running migration.*\n/g, '') // start of individual migration run
.replace(/Ran .* from .*\n .*\n\n/g, '') // end of individual migration run
.replace(/No changes were made\n\n/g, ''); // no changes during individual migration run
expect(result).toMatchInlineSnapshot(`
Lerna No changes were necessary. This workspace is up to date!
`);
expect(result).toContain(
'Lerna No changes were necessary. This workspace is up to date!'
);
}, 1000000);
});
@ -77,16 +70,10 @@ describe('Lerna Smoke Tests', () => {
expect(result).toMatchInlineSnapshot(`
> package-1:print-name
> echo test-package-1
test-package-1
Lerna (powered by Nx) Successfully ran target print-name for project package-1
`);
}, 1000000);
});