mirror of
https://github.com/oven-sh/bun
synced 2026-02-11 11:29:02 +00:00
fix node-module-module.test.js on windows (#10620)
This commit is contained in:
@@ -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", () => {
|
||||
|
||||
Reference in New Issue
Block a user