Skip to content

Commit d012461

Browse files
committed
Refactor: Update version test assertions to use expect.stringContaining for JSON output
1 parent 9dc2e67 commit d012461

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

scripts/release/__tests__/version.test.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -252,13 +252,13 @@ describe('Version', () => {
252252
expect(fspExtra.writeFile).toHaveBeenCalledWith(
253253
CODE_PACKAGE_JSON_PATH,
254254
// this call is the write that removes the "deferredNextVersion" property
255-
JSON.stringify({ version: currentVersion }, null, 2)
255+
expect.stringContaining(JSON.stringify({ version: currentVersion }, null, 2))
256256
);
257257
}
258258

259259
expect(fspExtra.writeFile).toHaveBeenCalledWith(
260260
CODE_PACKAGE_JSON_PATH,
261-
JSON.stringify({ version: expectedVersion }, null, 2)
261+
expect.stringContaining(JSON.stringify({ version: expectedVersion }, null, 2))
262262
);
263263
expect(fspExtra.writeFile).toHaveBeenCalledWith(
264264
MANAGER_API_VERSION_PATH,
@@ -270,13 +270,15 @@ describe('Version', () => {
270270
);
271271
expect(fspExtra.writeFile).toHaveBeenCalledWith(
272272
A11Y_PACKAGE_JSON_PATH,
273-
JSON.stringify(
274-
{
275-
// should update package version
276-
version: expectedVersion,
277-
},
278-
null,
279-
2
273+
expect.stringContaining(
274+
JSON.stringify(
275+
{
276+
// should update package version
277+
version: expectedVersion,
278+
},
279+
null,
280+
2
281+
)
280282
)
281283
);
282284
expect(execaCommand).toHaveBeenCalledWith('yarn install --mode=update-lockfile', {
@@ -297,7 +299,9 @@ describe('Version', () => {
297299
expect(fspExtra.writeFile).toHaveBeenCalledTimes(1);
298300
expect(fspExtra.writeFile).toHaveBeenCalledWith(
299301
CODE_PACKAGE_JSON_PATH,
300-
JSON.stringify({ version: '1.0.0', deferredNextVersion: '2.0.0-beta.0' }, null, 2)
302+
expect.stringContaining(
303+
JSON.stringify({ version: '1.0.0', deferredNextVersion: '2.0.0-beta.0' }, null, 2)
304+
)
301305
);
302306
expect(execaCommand).not.toHaveBeenCalled();
303307
});

0 commit comments

Comments
 (0)