Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Firefox compatibility to stack trace test #171

Merged
merged 3 commits into from
Dec 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/moduleEnv.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ var moduleWrapper0 = Module.wrapper[0],
// Test the regular expresssion at https://regex101.com/r/dvnZPv/2 and also check out testLib/constModule.js.
matchConst = /(^|\s|\}|;)const(\/\*|\s|{)/gm,
// Required for importing modules with shebang declarations, since NodeJS 12.16.0
shebang = /^(#!).+/,
shebang = /^#!.+/,
nodeRequire,
currentModule;

Expand Down
21 changes: 17 additions & 4 deletions testLib/sharedTestCases.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,18 @@ module.exports = function () {
try {
throwError();
} catch (err) {
expect(err.stack.split("\n")[1]).to.match(/:6:26/);

// Firefox implements a different error-stack format,
// but does offer line and column numbers on errors: we use
// those instead.
if (err.lineNumber !== undefined && err.columnNumber !== undefined) {
expect(err.lineNumber).to.equal(6)
expect(err.columnNumber).to.equal(26)
}
// This is for the V8 stack trace format (Node, Chrome)
else {
expect(err.stack.split("\n")[1]).to.match(/:6:26/);
}
}
});

Expand Down Expand Up @@ -409,8 +420,10 @@ module.exports = function () {
});

it("should be possible to rewire shebang modules", function () {
expect(function () {
rewire("./shebangModule");
}).to.not.throwError();
var shebangModule = rewire("./shebangModule");
var shebangs = shebangModule.__get__("shebangs");

expect(typeof shebangs).to.be("function");
expect(shebangModule.shebangs()).to.be(true);
});
};
2 changes: 1 addition & 1 deletion testLib/shebangModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ function shebangs() {
return true;
}

module.exports.shebangs = shebangs;
exports.shebangs = shebangs;