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:
parent
4b4226d2e0
commit
8b02fd48f7
@ -13,17 +13,13 @@ import {
|
|||||||
|
|
||||||
expect.addSnapshotSerializer({
|
expect.addSnapshotSerializer({
|
||||||
serialize(str: string) {
|
serialize(str: string) {
|
||||||
return (
|
return str
|
||||||
str
|
.replace(/(\r\n|\n)+/g, '\n')
|
||||||
// Not all package managers print the package.json path in the output
|
.replace(/\n\s+/g, '\n')
|
||||||
.replace(tmpProjPath(), '')
|
.replace(/\s+\n/g, '\n')
|
||||||
.replace('/private', '')
|
.replace(tmpProjPath(), '')
|
||||||
.replace('/packages/package-1', '')
|
.replace('/private', '')
|
||||||
// We trim each line to reduce the chances of snapshot flakiness
|
.replace('/packages/package-1', '');
|
||||||
.split('\n')
|
|
||||||
.map((r) => r.trim())
|
|
||||||
.join('\n')
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
test(val: string) {
|
test(val: string) {
|
||||||
return val != null && typeof 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(/Running migration.*\n/g, '') // start of individual migration run
|
||||||
.replace(/Ran .* from .*\n .*\n\n/g, '') // end 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
|
.replace(/No changes were made\n\n/g, ''); // no changes during individual migration run
|
||||||
expect(result).toMatchInlineSnapshot(`
|
expect(result).toContain(
|
||||||
|
'Lerna No changes were necessary. This workspace is up to date!'
|
||||||
Lerna No changes were necessary. This workspace is up to date!
|
);
|
||||||
|
|
||||||
|
|
||||||
`);
|
|
||||||
}, 1000000);
|
}, 1000000);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -76,18 +69,12 @@ describe('Lerna Smoke Tests', () => {
|
|||||||
.replace('$ echo test-package-1', '> echo test-package-1');
|
.replace('$ echo test-package-1', '> echo test-package-1');
|
||||||
expect(result).toMatchInlineSnapshot(`
|
expect(result).toMatchInlineSnapshot(`
|
||||||
|
|
||||||
> package-1:print-name
|
> package-1:print-name
|
||||||
|
> echo test-package-1
|
||||||
|
test-package-1
|
||||||
|
Lerna (powered by Nx) Successfully ran target print-name for project package-1
|
||||||
|
|
||||||
> echo test-package-1
|
`);
|
||||||
test-package-1
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Lerna (powered by Nx) Successfully ran target print-name for project package-1
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
`);
|
|
||||||
}, 1000000);
|
}, 1000000);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user