Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to generate mocha test case report and show using Jenkins?

I am doing mocha unit testing for my JavaScript functions. I am running mocha in a browser not using Node. I am using require.js to load files.

When I do mocha.run() it shows reports in the browser.

Now I want to make a Jenkins job to display the report.

So how do I generate the report file so that I can provide it to Jenkins?

like image 992
Sandeep Avatar asked Oct 22 '25 05:10

Sandeep


2 Answers

Run the command

$ mocha ./test.js --reporter mocha-junit-reporter --reporter-options ./test-results.xml

For docker file use below command

CMD ["mocha", "./test.js" , "--reporter", "mocha-junit-reporter", "--reporter-options","./test-results.xml"]

Both command will do the same. test-results.xml file be generate in the folder .

like image 120
Bilal Mubeen Avatar answered Oct 24 '25 08:10

Bilal Mubeen


Running the command:

$ npm install mocha-junit-reporter --save-dev

Will generate an XML file that you can give to Jenkins

like image 22
ARR Avatar answered Oct 24 '25 07:10

ARR



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!