Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d1179c4

Browse files
committed
Use glob instead of opendir to gather Allure Mocha test samples (fix node 18 tests)
1 parent 0f269e3 commit d1179c4

9 files changed

+104
-13
lines changed

.pnp.cjs

Lines changed: 45 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
135 KB
Binary file not shown.
70.8 KB
Binary file not shown.
164 KB
Binary file not shown.
71.9 KB
Binary file not shown.
108 KB
Binary file not shown.

packages/allure-mocha/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
"eslint-plugin-n": "^17.0.0",
8181
"eslint-plugin-no-null": "^1.0.2",
8282
"eslint-plugin-prefer-arrow": "^1.2.3",
83+
"glob": "^10.4.1",
8384
"mocha": "^10.2.0",
8485
"npm-run-all2": "^6.1.2",
8586
"rimraf": "^5.0.1",

packages/allure-mocha/test/fixtures/runner.js

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
// cjs: const { opendir } = require("fs/promises");
1+
// cjs: const { Glob } = require("glob");
22
// cjs: const path = require("path");
33
// cjs: const Mocha = require("mocha");
44
// cjs: const AllureReporter = require("allure-mocha");
5-
// esm: import { opendir } from "fs/promises";
5+
// esm: import { Glob } from "glob";
66
// esm: import path from "path";
77
// esm: import { fileURLToPath } from "url";
88
// esm: import Mocha from "mocha";
@@ -44,18 +44,10 @@ const mocha = new Mocha({
4444
color: false,
4545
});
4646

47-
const specFilePattern = /\.spec\./;
48-
49-
const loadSpecFiles = async () => {
50-
for await (const node of await opendir(dirname, { recursive: true })) {
51-
if (node.isFile() && specFilePattern.test(node.name)) {
52-
mocha.addFile(path.join(node.path ?? node.parentPath, node.name));
53-
}
54-
}
55-
};
56-
5747
const run = async () => {
58-
await loadSpecFiles();
48+
for await (const file of new Glob("./**/*.spec.*", {})) {
49+
mocha.addFile(path.resolve(file));
50+
}
5951
await mocha.loadFilesAsync();
6052
mocha.run((failures) => process.exit(failures));
6153
};

yarn.lock

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4497,6 +4497,7 @@ __metadata:
44974497
eslint-plugin-n: "npm:^17.0.0"
44984498
eslint-plugin-no-null: "npm:^1.0.2"
44994499
eslint-plugin-prefer-arrow: "npm:^1.2.3"
4500+
glob: "npm:^10.4.1"
45004501
mocha: "npm:^10.2.0"
45014502
npm-run-all2: "npm:^6.1.2"
45024503
rimraf: "npm:^5.0.1"
@@ -8436,6 +8437,21 @@ __metadata:
84368437
languageName: node
84378438
linkType: hard
84388439

8440+
"glob@npm:^10.4.1":
8441+
version: 10.4.1
8442+
resolution: "glob@npm:10.4.1"
8443+
dependencies:
8444+
foreground-child: "npm:^3.1.0"
8445+
jackspeak: "npm:^3.1.2"
8446+
minimatch: "npm:^9.0.4"
8447+
minipass: "npm:^7.1.2"
8448+
path-scurry: "npm:^1.11.1"
8449+
bin:
8450+
glob: dist/esm/bin.mjs
8451+
checksum: 10/d7bb49d2b413f77bdd59fea4ca86dcc12450deee221af0ca93e09534b81b9ef68fe341345751d8ff0c5b54bad422307e0e44266ff8ad7fbbd0c200e8ec258b16
8452+
languageName: node
8453+
linkType: hard
8454+
84398455
"glob@npm:^6.0.1":
84408456
version: 6.0.4
84418457
resolution: "glob@npm:6.0.4"
@@ -9474,6 +9490,19 @@ __metadata:
94749490
languageName: node
94759491
linkType: hard
94769492

9493+
"jackspeak@npm:^3.1.2":
9494+
version: 3.4.0
9495+
resolution: "jackspeak@npm:3.4.0"
9496+
dependencies:
9497+
"@isaacs/cliui": "npm:^8.0.2"
9498+
"@pkgjs/parseargs": "npm:^0.11.0"
9499+
dependenciesMeta:
9500+
"@pkgjs/parseargs":
9501+
optional: true
9502+
checksum: 10/5032c43c0c1fb92e72846ce496df559214253bc6870c90399cbd7858571c53169d9494b7c152df04abcb75f2fb5e9cffe65651c67d573380adf3a482b150d84b
9503+
languageName: node
9504+
linkType: hard
9505+
94779506
"jasmine-core@npm:~3.99.0":
94789507
version: 3.99.1
94799508
resolution: "jasmine-core@npm:3.99.1"
@@ -10614,6 +10643,13 @@ __metadata:
1061410643
languageName: node
1061510644
linkType: hard
1061610645

10646+
"lru-cache@npm:^10.2.0":
10647+
version: 10.2.2
10648+
resolution: "lru-cache@npm:10.2.2"
10649+
checksum: 10/ff1a496d30b5eaec2c9079080965bb0cede203cf878371f7033a007f1e54cd4aa13cc8abf7ccec4c994a83a22ed5476e83a55bb57cc07e6c1547a42937e42c37
10650+
languageName: node
10651+
linkType: hard
10652+
1061710653
"lru-cache@npm:^4.0.1":
1061810654
version: 4.1.5
1061910655
resolution: "lru-cache@npm:4.1.5"
@@ -10972,6 +11008,13 @@ __metadata:
1097211008
languageName: node
1097311009
linkType: hard
1097411010

11011+
"minipass@npm:^7.1.2":
11012+
version: 7.1.2
11013+
resolution: "minipass@npm:7.1.2"
11014+
checksum: 10/c25f0ee8196d8e6036661104bacd743785b2599a21de5c516b32b3fa2b83113ac89a2358465bc04956baab37ffb956ae43be679b2262bf7be15fce467ccd7950
11015+
languageName: node
11016+
linkType: hard
11017+
1097511018
"minizlib@npm:^2.1.1, minizlib@npm:^2.1.2":
1097611019
version: 2.1.2
1097711020
resolution: "minizlib@npm:2.1.2"
@@ -12024,6 +12067,16 @@ __metadata:
1202412067
languageName: node
1202512068
linkType: hard
1202612069

12070+
"path-scurry@npm:^1.11.1":
12071+
version: 1.11.1
12072+
resolution: "path-scurry@npm:1.11.1"
12073+
dependencies:
12074+
lru-cache: "npm:^10.2.0"
12075+
minipass: "npm:^5.0.0 || ^6.0.2 || ^7.0.0"
12076+
checksum: 10/5e8845c159261adda6f09814d7725683257fcc85a18f329880ab4d7cc1d12830967eae5d5894e453f341710d5484b8fdbbd4d75181b4d6e1eb2f4dc7aeadc434
12077+
languageName: node
12078+
linkType: hard
12079+
1202712080
"path-to-regexp@npm:^6.2.0, path-to-regexp@npm:^6.2.1":
1202812081
version: 6.2.1
1202912082
resolution: "path-to-regexp@npm:6.2.1"

0 commit comments

Comments
 (0)