Skip to content

Commit bdd2708

Browse files
committed
test: sort files array before comparing to expectation
Improves test stability as under certain circumstances the order of files returned by `git diff-tree` might differ.
1 parent 1e99ccd commit bdd2708

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

test/integration.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ test.serial('Prepare from a shallow clone', async t => {
6464
};
6565
await t.context.m.prepare(pluginConfig, {logger: t.context.logger, options: {repositoryUrl, branch}, nextRelease});
6666

67-
t.deepEqual(await gitCommitedFiles(), ['dist/file.js', 'package.json']);
67+
t.deepEqual((await gitCommitedFiles()).sort(), ['dist/file.js', 'package.json'].sort());
6868
const [commit] = await gitGetCommits();
6969
t.is(commit.subject, `Release version ${nextRelease.version} from branch ${branch}`);
7070
t.is(commit.body, `${nextRelease.notes}\n`);
@@ -93,7 +93,7 @@ test.serial('Prepare from a detached head repository', async t => {
9393
};
9494
await t.context.m.prepare(pluginConfig, {logger: t.context.logger, options: {repositoryUrl, branch}, nextRelease});
9595

96-
t.deepEqual(await gitCommitedFiles(), ['dist/file.js', 'package.json']);
96+
t.deepEqual((await gitCommitedFiles()).sort(), ['dist/file.js', 'package.json'].sort());
9797
const [commit] = await gitGetCommits();
9898
t.is(commit.subject, `Release version ${nextRelease.version} from branch ${branch}`);
9999
t.is(commit.body, `${nextRelease.notes}\n`);

test/prepare.test.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ test.serial(
4747
// Verify the remote repo has a the version referencing the same commit sha at the local head
4848
const [commit] = await gitGetCommits();
4949
// Verify the files that have been commited
50-
t.deepEqual(await gitCommitedFiles(), ['CHANGELOG.md', 'npm-shrinkwrap.json', 'package-lock.json', 'package.json']);
50+
t.deepEqual(
51+
(await gitCommitedFiles()).sort(),
52+
['CHANGELOG.md', 'npm-shrinkwrap.json', 'package-lock.json', 'package.json'].sort()
53+
);
5154

5255
t.is(commit.subject, `chore(release): ${nextRelease.version} [skip ci]`);
5356
t.is(commit.body, `${nextRelease.notes}\n`);

0 commit comments

Comments
 (0)