diff --git a/test/fixture/scenario/nyc-mocha-cjs-bridge/add.js b/test/fixture/scenario/nyc-mocha-cjs-bridge/add.js new file mode 100644 index 000000000..e536183ce --- /dev/null +++ b/test/fixture/scenario/nyc-mocha-cjs-bridge/add.js @@ -0,0 +1 @@ +export default (a, b) => a + b diff --git a/test/fixture/scenario/nyc-mocha-cjs-bridge/cwd.js b/test/fixture/scenario/nyc-mocha-cjs-bridge/cwd.js new file mode 100644 index 000000000..5c3fa4d52 --- /dev/null +++ b/test/fixture/scenario/nyc-mocha-cjs-bridge/cwd.js @@ -0,0 +1,3 @@ +"use strict" + +process.chdir(__dirname) diff --git a/test/fixture/scenario/nyc-mocha-cjs-bridge/require-add.js b/test/fixture/scenario/nyc-mocha-cjs-bridge/require-add.js new file mode 100644 index 000000000..677a47820 --- /dev/null +++ b/test/fixture/scenario/nyc-mocha-cjs-bridge/require-add.js @@ -0,0 +1,5 @@ +"use strict" + +require = require("../../../../")(module) +const add = require("./add").default +module.exports = add diff --git a/test/fixture/scenario/nyc-mocha-cjs-bridge/test/test.js b/test/fixture/scenario/nyc-mocha-cjs-bridge/test/test.js new file mode 100644 index 000000000..082f7f590 --- /dev/null +++ b/test/fixture/scenario/nyc-mocha-cjs-bridge/test/test.js @@ -0,0 +1,4 @@ +import assert from "assert" +import add from "../require-add" + +assert(add(1, 2), 3) diff --git a/test/scenario-tests.mjs b/test/scenario-tests.mjs index 0c11e3fb8..7151f298e 100644 --- a/test/scenario-tests.mjs +++ b/test/scenario-tests.mjs @@ -47,6 +47,19 @@ describe("scenarios", function () { , Promise.resolve()) ) + it("should work with nyc, mocha, and cjs bridge", () => { + const dirPath = path.resolve(testPath, "fixture/scenario/nyc-mocha-cjs-bridge") + const cwdPath = path.resolve(dirPath, "cwd.js") + const mochaPattern = path.resolve(dirPath, "test") + + return exec("nyc", [ + "--cwd", dirPath, + "-i", cwdPath, + "-i", pkgPath, + "mocha", mochaPattern + ], envAuto) + }) + it("should work with esmod-pmb", () => exec(nodePath, [path.resolve(testPath, "fixture/scenario/esmod-pmb/test.node.js")]) )