Skip to content

Commit c54539f

Browse files
chore: fix esm-utils tests when run without coverage (#6160)
1 parent dcc539a commit c54539f

4 files changed

Lines changed: 17 additions & 11 deletions

File tree

‎test/node-unit/esm-utils.spec.cjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ describe("esm-utils", function () {
5353
return expect(
5454
() =>
5555
esmUtils.requireOrImport(
56-
"../../test/node-unit/fixtures/mock-mocha-forbidden-exclusivity-err.ts",
56+
"../../test/node-unit/fixtures/commonjs/mock-mocha-forbidden-exclusivity-err.ts",
5757
),
5858
"to be rejected with error satisfying",
5959
{
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
Mock file that simulates a Mocha FORBIDDEN_EXCLUSIVITY error
3+
This error is thrown when .only is used in parallel mode
4+
5+
This fixture uses require(), so it lives in a folder with a "commonjs" package.json.
6+
The root package.json is "type": "module" which would otherwise make Node load this
7+
.ts file as ESM and leave "require" undefined.
8+
*/
9+
const { createForbiddenExclusivityError } = require('../../../../lib/errors.js');
10+
11+
const mockMocha = { isWorker: true };
12+
13+
throw createForbiddenExclusivityError(mockMocha);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"type": "commonjs"
3+
}

‎test/node-unit/fixtures/mock-mocha-forbidden-exclusivity-err.ts‎

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)