Closed haari006 closed 8 months ago
This is due to the fact that only Next knows how to import the @
imports. SafeTest also runs jest (or vitest) which doesn't know how to import those. You can either change them to traditional imports or you can add this to your package.json and rerun npm install to get a symlink on @
{
"dependencies": {
"@": "file:."
}
}
Hi @kolodny,
In jest we can specify name mappers like this.
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1'
}
@Urriel Good point. So digging in a bit more, it seems that just using the setup from the NextJS docs actually takes care of that alias. I updated the NextJS example to have this alias set using Vitest as well as Jest
@kolodny Thanks man
I'm using Nextjs and it's not recognizing imports with "@" but if i change to traditional import, it does recognize. Is there any way to define the "@" imports for safetest?
` FAIL src/app/tests/spec.safetest.tsx ● Test suite failed to run
Test Suites: 1 failed, 1 total Tests: 0 total Snapshots: 0 total Time: 3.275 s`