What is Jasmine?
Jasmine is a testing framework for Javascript and Typescript.
Enabling XML Output
Configure Jasmine to produce JUnit XML output.
Install the jasmine-reporters package
1npm install --save-dev jasmine-reporters
Create an instance of a JUnitXMLReporter to the top of your test file and add it to your Jasmine environment.
1import reporters from "jasmine-reporters";23var junitReporter = new reporters.JUnitXmlReporter({4 savePath: "tests/jasmine/reports",5 consolidateAll: false,6});7jasmine.getEnv().addReporter(junitReporter);89describe("HuntingSeason", () => {10 it("Bugs - `Duck Season`", () => {11 const season = new Season();12 expect(season.getCurrent()).toEqual("Duck");13 });1415 it("Daffy - `Rabbit Season`", () => {16 const season = new Season();17 expect(season.getCurrent()).toEqual("Rabbit");18 });19});
With this configuration, Jasmine will output an xml file in the tests/jasmine/reports directory.
Test Suite naming
Jasmine will use the test suite names for the file name and xml attributes by combining them with the JUnitXmlReporter settings. For example with the savePath set to "tests/jasmine/reports" the test suite named "HuntingSeason" will output to the file "tests/jasmine/reports/junitresults-HuntingSeason.xml".
The names of the test suites can be modified by providing a modifySuiteName() function. See the official docs for details.
Unfortunately this reporter does not support adding the file attribute to the XML.
Other Configuration
See an example of running Jasmine inside of a GitHub action here.


