Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Test reporting in pipelines for Typescript

Simmi Mourya
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 10, 2024

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. 

1 answer

0 votes
Saxea _Flowie_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 10, 2024

Hi @Simmi Mourya ,

Have you tried using jest-junit to generate the result in the supported locations?

Simmi Mourya
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 11, 2024

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.

Saxea _Flowie_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 16, 2024

Hi @Simmi Mourya ,

There is an existing thread that gives you an idea of what is displayed when the report files are picked up.

https://community.atlassian.com/t5/Bitbucket-questions/Where-do-I-view-pipeline-test-reports/qaq-p/689754?lightbox-message-images-1085506=54889iA170F3102F5D63E3

Hope this helps.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events