Skip to content

armgit / mocha

Public Imported from GitHub
0

☕️ Classic, reliable, trusted test framework for Node.js and the browser

fix: keep unknown config values from becoming test specs (#6244)

Lazizbek Ergashev15aa7d155486
diff --git a/lib/cli/unparse-args.js b/lib/cli/unparse-args.js
index c7edded2..a41bc332 100644
--- a/lib/cli/unparse-args.js
+++ b/lib/cli/unparse-args.js
@@ -23,10 +23,7 @@ const unparseOption = (name, value) => {
);
}
- if (name.includes(".")) {
- return [`--${name}=${String(value)}`];
- }
- return [`--${name}`, String(value)];
+ return [`--${name}=${String(value)}`];
};
const unparseMochaArgs = (opts) => {
diff --git a/test/node-unit/cli/unparse-args.spec.js b/test/node-unit/cli/unparse-args.spec.js
index 8b6c8145..7942c22a 100644
--- a/test/node-unit/cli/unparse-args.spec.js
+++ b/test/node-unit/cli/unparse-args.spec.js
@@ -49,14 +49,10 @@ describe("unparse-args", function () {
[
"test/a.spec.js",
"test/b.spec.js",
- "--require",
- "tsx",
- "--require",
- "./setup.js",
- "--reporter",
- "json",
- "--timeout",
- "0",
+ "--require=tsx",
+ "--require=./setup.js",
+ "--reporter=json",
+ "--timeout=0",
"--no-color",
"--bail",
],
@@ -70,7 +66,7 @@ describe("unparse-args", function () {
_: ["test/a.spec.js"],
}),
"to equal",
- ["test/a.spec.js", "--reporter", "json"],
+ ["test/a.spec.js", "--reporter=json"],
);
});
@@ -81,7 +77,17 @@ describe("unparse-args", function () {
reporter: "json",
}),
"to equal",
- ["--reporter", "json"],
+ ["--reporter=json"],
+ );
+ });
+
+ it("keeps the value of an unrecognized option attached to its flag", function () {
+ expect(
+ unparseMochaArgs({
+ $schema: "https://json.schemastore.org/mocharc.json",
+ }),
+ "to equal",
+ ["--$schema=https://json.schemastore.org/mocharc.json"],
);
});