Categories
Mastering Development

Jest test with TypeScript not recognizing @ symbol in imports [duplicate]

I’m setting up the tests for my Vue project (with TypeScript) using the Jest framework. Everything seems to work alright, except with the @ symbol in my imports, e.g., import { Foo } from ‘@/bar. Whether it’s in my test files or in the source code, it doesn’t understand it and returns: Cannot find module […]

Categories
Mastering Development

How can I change jest test report output directory?

I have jest.config.js as below: module.exports = { “roots”: [ “<rootDir>/src” ], “testMatch”: [ “**/__tests__/**/*.+(ts|tsx|js)”, “**/?(*.)+(spec|test).+(ts|tsx|js)” ], “transform”: { “^.+\\.(ts|tsx)$”: “ts-jest” }, “testResultsProcessor”: “jest-sonar-reporter”, “collectCoverage”: true, “collectCoverageFrom”: [ “**/*.{ts,js}”, “!**/node_modules/**” ], “coverageDirectory”: “dist”, “coverageReporters”: [“lcov”] } A report file test-report.xml is generated in the project root directory. How can I make it to be saved […]

Categories
Development

jest can’t produce coverage

I am in a react-native (expo SDK36) application , I have configured jest using the explanation from expo doc. This is how my jest configuration look like: { “jest”: { “testURL”: “http://localhost”, “preset”: “jest-expo”, “transformIgnorePatterns”: [ “node_modules/(?!(jest-)?react-native|react-clone-referenced-element|@react-native-community|expo(nent)?|@expo(nent)?/.*|react-navigation|@react-navigation/.*|@unimodules/.*|sentry-expo|native-base)” ], “coverageThreshold”: { “global”: { “statements”: 0, “branches”: 0, “functions”: 0, “lines”: 0 } }, “coveragePathIgnorePatterns”: [ “/node_modules/”, […]