When I try to run a test in jest that imports a file using the $lib alias, jest fails to run with the error Cannot find module '$lib/...'.
Add the following to jest.config.cjs:
module.exports = {
...,
moduleNameMapper: { '^\\$lib(.*)$': '<rootDir>/src/lib$1' },
}
The documentation can be found under Using with webpack.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With