From c60f7b25f435c6eb629756e0e88ecc2843d938ae Mon Sep 17 00:00:00 2001 From: William Killerud Date: Mon, 18 Nov 2024 11:14:12 +0100 Subject: [PATCH] test: make test robust for glob order randomness The literal order in the list isn't that important, as long as the directories and files are correct. --- test/publish-files-definitions.test.mjs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/test/publish-files-definitions.test.mjs b/test/publish-files-definitions.test.mjs index cb98107a..12901725 100644 --- a/test/publish-files-definitions.test.mjs +++ b/test/publish-files-definitions.test.mjs @@ -239,9 +239,13 @@ test("when a recursive glob is specified", async (t) => { // @ts-expect-error const { files } = await cli.publish(config(pattern, address, token, cwd)); - t.equal(files[4].pathname, "/client.js", "client.js should be packaged at /"); t.equal( - files[11].pathname, + files.find((f) => f.pathname.endsWith("client.js")).pathname, + "/client.js", + "client.js should be packaged at /", + ); + t.equal( + files.find((f) => f.pathname.endsWith("checkboxes.svg")).pathname, "/icons/checkboxes.svg", "svgs should be packaged under /icons", ); @@ -255,7 +259,11 @@ test("when a non recursive glob is specified", async (t) => { const nested = files.filter((file) => file.pathname.includes("icons")); - t.equal(files[4].pathname, "/client.js", "client.js should be packaged at /"); + t.equal( + files.find((f) => f.pathname.endsWith("client.js")).pathname, + "/client.js", + "client.js should be packaged at /", + ); t.equal(nested.length, 0, "no nested files should be present"); });