Closed trinode closed 3 years ago
The behavior that you're seeing indicates that there's an issue with how your transpiled source code maps to back to your original source code.
This may be an issue in Wallaby but I suspect it's related to something in your configuration leading to bad source maps.
Would you be able to send us your:
This should give us enough information to try and reproduce your setup and see if we have the same problem. Alternatively, if you're able, it would be great if you could create a sample repo for us that has the same problem.
jest-config.js
module.exports = {
roots: ["<rootDir>"],
collectCoverageFrom: ["src/**/*", "!**/test/**/*", "!**/*.snap", "!**/main.js", "!src/ts/**/*", "!src/server/debug/**/*"],
moduleFileExtensions: ["js", "svelte", "ts"],
setupFiles: ["<rootDir>/test/setup-tests.js"],
setupFilesAfterEnv: ["@testing-library/jest-dom/extend-expect"],
testMatch: ["**/**/*.spec.*", "!**/*.snap"],
transform: {
"^.+\\.js$": "babel-jest",
"^.+\\.svelte$": "jest-transform-svelte",
"^.+\\.svg$": "<rootDir>/test/svg-transform/index.js",
"^.+\\.tsx?$": "ts-jest"
},
moduleNameMapper: {
"^@/components(.*)$": "<rootDir>/src/components$1",
"^@/svg(.*)$": "<rootDir>/src/svg$1",
"^@/utils(.*)$": "<rootDir>/src/utils$1",
"^@/src(.*)$": "<rootDir>/src/$1",
"\\.(css|scss)$": '<rootDir>/test/mock-style.js'
},
testResultsProcessor: "jest-teamcity-reporter"
};
tsconfig.json
{
"version": "3.9.5",
"compilerOptions": {
"outDir": "./dist/server",
"lib": ["es5", "es6", "dom"],
"target": "ES6",
"module": "commonjs",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"esModuleInterop": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"resolveJsonModule": true,
"allowJs": true,
"inlineSourceMap": true
},
"include": ["./src/server/**/*"],
"exclude": ["./node_modules", "./src/ts", "**/*.spec.ts"],
}
babel.config.js
module.exports = api => {
api.cache(true);
if (process.env.NODE_ENV === "test") {
return {
presets: [
[
"@babel/preset-env",
{
targets: {
node: "current",
esmodules: true
}
}
]
]
};
}
return {
presets: [
[
"@babel/preset-env",
{
targets: {
browsers: ["ie >= 11"]
},
modules: false,
spec: true,
forceAllTransforms: true,
useBuiltIns: "usage",
corejs: 3
}
]
]
};
};
We have created a sample repository with the necessary dependencies and your configuration and everything is working for us. Could you please try cloning and running the sample repo that we created to confirm that you're not getting the links on the wrong lines?
The only key difference in our configuration and yours that we think could potentially cause a problem is the setupFiles
in your jest configuration:
jest.config.js
...
- setupFiles: ["<rootDir>/test/setup-tests.js"],
...
If the sample repo that we provided is working for you, please migrate parts of your code from your project to the sample to isolate the problem. Alternatively, you may provide us with a sample repo that has the problem and we can investigate what's going on for you.
Closing this issue as we haven't heard back.
Issue description or question
Hi there, I'm having issues whereby some tests are not being identified as tests or maybe it's just the display of the
debug | view story | profile | focus
bar above the tests that's not working.I can see a couple of instances:-
I this one there are 2 describe blocks, the second one's tests are not identified (line 68 onwards):-
and another example, slightly different (it just stops recognising tests at a certain point):-
In this one it recognises a top level function as a test:-
Commenting out the function does let it find the first test:-
however it's interesting how the annotation from wallaby is on the wrong line (20 vs 48) - is this a problem with it not knowing about the original source file during transpiration or similar?
Wallaby diagnostics report