Closed wilgert closed 4 years ago
To try and get as close to your setup as possible, I have created this sample repo with your package.json dependencies and devDependencies as is. Had also added src
from freshly generated Angular CLI v9 app, and added simple Jest config as described in the jest-preset-angular
docs.
Running Wallaby automatic config doesn't seem to produce any issues:
I have even tried to make the sample test to look like yours by adding async
and await fixture.whenStable();
.
Can you please try my sample repo (git clone
, npm i
and run Wallaby auto-config RC), to see if you can reproduce the issue? If it is not reproducible, can you please take a look what's missing/different from your repo? Dependencies are exactly the same as yours, so may be it is some Jest/TS config missing to reproduce the issue.
I also have no issue running the example project. Indicators appear at the right location.
It's a pretty old project (started in 2017) so it is likey that there is some configuration somewhere that causes this. In the past jasmine was used and wallaby was used with a config file. I think I've removed all the old config, but I will have a look. Could you give me a hint what sort of config is most likely to be causing this?
I changed the jest.config.js to be as minimalist as your example repo, this also does not help.
Could you give me a hint what sort of config is most likely to be causing this?
It is likely some source mapping issue. So anything in your config files that can affect source code transformation (tsconfig, jest config).
If you can't easily find the config that is causing the issue in your project, perhaps the best way is to try remove any business sensitive code form your project and share it with us on GH or by sending to hello@wallabyjs.com. I don't think actual test/app code matters, you should be able to repro even on a simple test if it is indeed source mapping issue, so it should be easy to remove all source code, but leave one test (and relevant configs).
I was having the same issue yesterday, however today it was fine. Closing down other IDEs you have open with wallaby might help, as well as restarting your PC
@wilgert - did @ioanb7's suggestion help you? Have you been able to look at reproducing the problem outside of your test/app code?
@wilgert - did @ioanb7's suggestion help you? Have you been able to look at reproducing the problem outside of your test/app code?
Not yet, have been working on another project for the last couple of days. Will get back to this one next week!
Then again: I have definitely restarted my PC and IDE. I think this issue has always been there with this particular project.
I have created a reproduction of the issue by copying files from my project and then removing anything that is not necessary. You can find it here: https://github.com/wilgert/wallaby-2434
In VSCode the indicators are also misaligned.
Thanks for the sample repo. We can duplicate the issue with your repo. One quick note: the repo has a problem with package name in package.json
so npm install
doesn't work properly. Removing spaces from the package name fixes the problem.
Thanks for providing the sample repo. We've been able to identify the issue and it is a bug in ts-jest
source map URL generation.
To see the problem outside of Wallaby, change your 'should render a greeting' test as shown below:
it('should render a greeting', () => {
+ throw new Error('Error');
fixture.detectChanges();
expect(fixture.debugElement.nativeElement.innerHTML).toEqual('<h1>Hi!</h1>');
});
When you run npx jest
, you will see that jest is reporting that the error is on line 23 instead of line 27.
To not make you wait until the fix in ts-jest
is available, we have made Wallaby tolerant to malformed source map URLs, so please update to the latest core v1.0.907 and the issue should be fixed for you.
If it's not possible for you to update Wallaby, you can modify your tsconfig.spec.json
file and set the mapRoot
setting to an empty string:
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/spec",
"module": "commonjs",
"sourceMap": true,
"allowJs": true,
+ "mapRoot": ""
},
"include": ["**/*.spec.ts", "**/*.d.ts"]
}
so that Jest and Wallaby can correctly map lines.
Thanks a lot @ArtemGovorov that works!
@smcenlly sorry for throwing you a curveball with the project name in package.json
.
This was also happening to me when I switched from ts-jest
to @swc/jest
. SWC wasn't producing sourcemaps at all. I added the sourcemaps
option to my jest file where I set the transform
option.
module.exports = {
displayName: "ih-api",
preset: "../../../jest.preset.js",
testEnvironment: "node",
transform: {
"^.+\\.[tj]s$": ["@swc/jest", { sourceMaps: true }]
},
moduleFileExtensions: ["ts", "js", "html"],
coverageDirectory: "../../../coverage/apps/ih-api",
setupFiles: ["../../../setupJest.js"]
};
Issue description or question
In one of my projects the coverage/error indicators are showing up on the wrong line. I've tried clearing the jest cache (using
jest --clearCache
) to no avail.Wallaby diagnostics report