Closed ilyoff closed 2 years ago
I assume that you are running your tests from your package.json
or from the CLI with craco test
?
Wallaby doesn't provide direct support for craco
which means that you will need to ensure that npx jest
runs from the CLI in order for Wallaby to work. I assume that you get the same failures when using npx jest
as you get when using Wallaby?
You may need to look at what the craco scripts are doing to create a jest.config.js
file that does the same thing in your project root for Wallaby / Jest CLI to use. Please also note that you can override Wallaby's jest automatic configuration to use a different jest configuration file if required (see our docs).
@smcenlly Hi, Simon, thank you for your response.
I have created jest.config.js
file, as mentioned in craco docs, checked npx jest
command, and got working tests. But wallaby still not working and I'm getting same errors.
Could you please try using this as your wallaby.js configuration file instead?
module.exports = () => {
return {
// tell wallaby to use automatic configuration
autoDetect: true,
testFramework: {
// the jest configuration file path (relative to project root)
configFile: './jest.config.wallaby.js'
}
}
};
There shouldn't be anything else that you need to do at this point if everything is working when you using npx jest
from the command line.
Assuming our last suggestion fixed your problem.
@smcenlly sorry for a long time answer. Yes, your suggestion really worked for me, thank you very much! But unfortunately, it works much slower than in video demos. It took about 8 minutes on the first run (about 1500 tests). Maybe, the possible reason is ts-auto-mock and avj packages usage in tests
The speed of Wallaby running your test is affected by your tests themselves, and what they're doing. For example, if you are doing something that is cryptographically complex (and expensive in terms of CPU cycles) then Wallaby will take longer to run your test. Similarly, if you are editing code that is common to your entire project (e.g. something infrastructural like Logging) then after that change, Wallaby will need to re-execute many tests, which may take longer than editing code that is only related to a single test.
I recommend using Wallaby's Test Profiler to see what it is your tests are doing and where the time is being taken. This should allow you to optimise your tests (or at the very least, understand why they are taking so long).
Issue description or question
Hello. I use create-react-app with typescript and craco package (react-app-rewired alternative). When I try to run wallaby, I'm getting following error on random jsx files:
But, if turn on autoDetect and trace flags in my wallaby config, I'm getting different kind of error:
Wallaby config
Wallaby diagnostics report
For "TypeError: this[type] is not a function…"
For "Cannot find module…" error