-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
use of source-map-support causes the wrong line numbers to appear in @swc/jest tests #3105
Comments
I'm seeing this as well with babel-jest when ever |
The issue is here remix/packages/remix-node/index.ts Line 3 in b0b544d
Jest probably installs this as well and they seem to collide. The line numbers are correct if this line is removed. I created a repro here with babel-jest: https://github.com/esamattis/remix-jest-line-numbers-bug I also created a patch-package patch here which can be used to fix this in projects. But this is not probably not the best way to fix this since it means coding jest specific things into Remix. Maybe we can add a global flag to disable Remix source maps in the test frameworks 🤔 Eg. if (!process.env.REMIX_DISABLE_SOURCE_MAPS) {
sourceMapSupport.install();
} and Jest users could add Sent a PR #3374 |
Just to note: this issue happens with ts-jest too and the same workaround works for it too. |
Since there has not been any progress I'm commenting to say that this worked for me with ts-jest as you say. Would love to see the PR above be put into the application. |
If anyone encounters this issue you may use // file: ./app/jest/source-map-support.stub.ts
/* eslint-disable no-console */
export const install = () => {
let caller = "[UNKNOWN]";
// Play some 4D chess
const o = Error.prepareStackTrace;
try {
Error.prepareStackTrace = (_err, stackTraces) => {
const c = stackTraces[1];
if (c) caller = `${c.getFileName()}:${c.getLineNumber()}:${c.getColumnNumber()}`;
};
const a = new Error();
void a.stack;
} finally {
Error.prepareStackTrace = o;
console.error(
`Warning! Someone tried to install source map support in a jest test. This will cause all stack traces to be malformed! The offender:\n${caller}`,
);
}
}; Then in your jest config you may:
|
This should be obsolete once v2 launches since we've removed the automatic inclusion of source map support and that will be handled in userland: #7009 |
What version of Remix are you using?
1.4.0
Steps to Reproduce
kulshekhar/ts-jest#2372
if for any reason
@remix-run/node
is pulled into a test, this issue will happen. should either ENV flag outside of test, or version flag to only include on older node versions?Expected Behavior
should show correct typescript line numbers
Actual Behavior
line numbers get mangled
The text was updated successfully, but these errors were encountered: