Skip to content

Commit 67eeb87

Browse files
committed
test(unit-plugin-tester): address side-effect from the presence of low level signal-exit dark magic
1 parent 2f41466 commit 67eeb87

File tree

1 file changed

+33
-3
lines changed

1 file changed

+33
-3
lines changed

test/unit-plugin-tester.test.ts

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5018,6 +5018,10 @@ describe('tests targeting the FixtureOptions interface', () => {
50185018

50195019
await runPluginTester(
50205020
getDummyPluginOptions({
5021+
// ? We have to do this once at the beginning because the signal-exit
5022+
// ? package dark magic deep in node/npm internals has side-effects on
5023+
// ? assert.equal
5024+
setup: () => void equalSpy.mockClear(),
50215025
fixtures: getFixturePath('creates-output-file')
50225026
})
50235027
);
@@ -5035,6 +5039,7 @@ describe('tests targeting the FixtureOptions interface', () => {
50355039

50365040
await runPluginTester(
50375041
getDummyPresetOptions({
5042+
setup: () => void equalSpy.mockClear(),
50385043
fixtures: getFixturePath('option-fixtureOutputName')
50395044
})
50405045
);
@@ -5053,6 +5058,7 @@ describe('tests targeting the FixtureOptions interface', () => {
50535058

50545059
await runPluginTester(
50555060
getDummyPluginOptions({
5061+
setup: () => void equalSpy.mockClear(),
50565062
fixtures: getFixturePath('option-fixtureOutputExt')
50575063
})
50585064
);
@@ -5073,6 +5079,10 @@ describe('tests targeting the FixtureOptions interface', () => {
50735079

50745080
await runPluginTester(
50755081
getDummyPluginOptions({
5082+
// ? We have to do this once at the beginning because the signal-exit
5083+
// ? package dark magic deep in node/npm internals has side-effects on
5084+
// ? assert.equal
5085+
setup: () => void equalSpy.mockClear(),
50765086
fixtures: getFixturePath('option-fixtureOutputExt')
50775087
})
50785088
);
@@ -5091,6 +5101,7 @@ describe('tests targeting the FixtureOptions interface', () => {
50915101

50925102
await runPluginTester(
50935103
getDummyPresetOptions({
5104+
setup: () => void equalSpy.mockClear(),
50945105
fixtures: getFixturePath('option-fixtureOutputExt-no-dot')
50955106
})
50965107
);
@@ -5111,13 +5122,32 @@ describe('tests targeting the TestObject interface', () => {
51115122
it('accepts an array value for `tests`', async () => {
51125123
expect.hasAssertions();
51135124

5114-
await runPluginTester(getDummyPluginOptions({ tests: [simpleTest] }));
5115-
await runPluginTester(getDummyPresetOptions({ tests: [simpleTest] }));
5125+
await runPluginTester(
5126+
getDummyPluginOptions({
5127+
// ? We have to do this once at the beginning because the signal-exit
5128+
// ? package dark magic deep in node/npm internals has side-effects on
5129+
// ? assert.equal
5130+
setup: () => void equalSpy.mockClear(),
5131+
tests: [simpleTest]
5132+
})
5133+
);
5134+
5135+
expect(itSpy).toHaveBeenCalledTimes(1);
5136+
5137+
expect(equalSpy.mock.calls).toMatchObject([
5138+
[simpleTest, simpleTest, expect.any(String)]
5139+
]);
5140+
5141+
await runPluginTester(
5142+
getDummyPresetOptions({
5143+
setup: () => void equalSpy.mockClear(),
5144+
tests: [simpleTest]
5145+
})
5146+
);
51165147

51175148
expect(itSpy).toHaveBeenCalledTimes(2);
51185149

51195150
expect(equalSpy.mock.calls).toMatchObject([
5120-
[simpleTest, simpleTest, expect.any(String)],
51215151
[simpleTest, simpleTest, expect.any(String)]
51225152
]);
51235153
});

0 commit comments

Comments
 (0)