https://support.atlassian.com/bitbucket-cloud/docs/test-reporting-in-pipelines/
Do we have similar instructions for JS/TS based project where jest is being used to run unit tests.
Hi @Simmi Mourya ,
Have you tried using jest-junit to generate the result in the supported locations?
Hi @Saxea _Flowie_ , thank you for your response. I am using jest-junit. This is my package.json
"scripts": {
"test": "jest --coverage",
},
"jest": { "collectCoverage": true,
"reporters": ["default", "jest-junit"],
"coverageThreshold": {
"global": {
"lines": 95
}
},
"collectCoverageFrom": [
"**/*.(t|j)s"
],
"coverageDirectory": "../server/test-reports",}
And this is my unit-test step in bitbucket-pipelines.yaml
- step: &unit-test
name: Run jest unit test
caches:
- npm
script:
- cd server
- npm config list
- npm ci
- echo "Running Jest unit tests with coverage"
- npm run test
artifacts:
- server/test-reports/**/*
1. The pipeline step generates the server/test-reports/**/* but I can't browse the test-reports directly from bitbucket UI, it only lets me download the zip of this artifact. Is there a way to view reports from bitbucket UI itself?
This is what the test-reports directory looks like.
test-reports % tree -L 3
.
├── clover.xml
├── coverage-final.json
├── lcov-report
│ ├── base.css
│ ├── block-navigation.js
│ ├── bello
│ │ ├── bello.service.ts.html
│ │ ├── dto
│ │ └── index.html
│ ├── favicon.png
│ ├── index.html
│ ├── prettify.css
│ ├── prettify.js
│ ├── sort-arrow-sprite.png
│ ├── sorter.js
│ └── hello
│ ├── dto
│ ├── index.html
│ ├── hello.controller.ts.html
│ └── hello.service.ts.html
└── lcov.info
2. npm run test also generates a junit.xml inside the server folder, I'm not quite sure how to interpret/use it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Simmi Mourya ,
There is an existing thread that gives you an idea of what is displayed when the report files are picked up.
Hope this helps.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.