fix node-module-module.test.js on windows (#10620)

This commit is contained in:
Dylan Conway
2024-04-28 16:54:47 -07:00
committed by GitHub
parent 84d81c3002
commit c7aed7e0a3
4 changed files with 37 additions and 34 deletions

View File

@@ -87,21 +87,25 @@ test("Overwriting Module.prototype.require", () => {
expect(exitCode).toBe(0);
});
test("Module.prototype._compile", () => {
test.each([
"/file/name/goes/here.js",
"file/here.js",
"file\\here.js",
"/file\\here.js",
"\\file\\here.js",
"\\file/here.js",
])("Module.prototype._compile", filename => {
const module = new Module("module id goes here");
const starting_exports = module.exports;
const r = module._compile(
"module.exports = { module, exports, require, __filename, __dirname }",
"/file/path/goes/here.js",
);
const r = module._compile("module.exports = { module, exports, require, __filename, __dirname }", filename);
expect(r).toBe(undefined);
expect(module.exports).not.toBe(starting_exports);
const { module: m, exports: e, require: req, __filename: fn, __dirname: dn } = module.exports;
expect(m).toBe(module);
expect(e).toBe(starting_exports);
expect(req).toBe(module.require);
expect(fn).toBe("/file/path/goes/here.js");
expect(dn).toBe("/file/path/goes");
expect(fn).toBe(filename);
expect(dn).toBe(path.dirname(filename));
});
test("Module._extensions", () => {