Categories
Mastering Development

How to configure test coverage visualisation in gitlab CICD?

I am trying to configure test coverage visualisation with reference to official documentation(https://docs.gitlab.com/ee/user/project/merge_requests/test_coverage_visualization.html), I tried with the same, but my pipeline failed hence no report is shown on merge requests, Our project stacks are NodeJS – Typescript. For testing we use JEST framework. I tried in many ways, but no luck. can anyone help me […]

Categories
Mastering Development

NestJS Testing: decorator is not a function

My dependencies: "@nestjs/common": "7.4.4", "@nestjs/core": "7.4.4", "typescript": "4.0.2", "jest": "26.4.2", "jest-junit": "11.1.0", "ts-jest": "26.3.0", I have a custom decorator: import { Inject } from "@nestjs/common"; import { DATABASE_SERVICE } from "./database.constants"; export const InjectDatabase = () => Inject(DATABASE_SERVICE); I use it in constructor for a service I’m willing to cover with tests: import { DatabaseService, […]

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/”, […]