Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
jasmine-reporters
Advanced tools
The jasmine-reporters npm package provides a set of reporters for the Jasmine testing framework. These reporters can generate test results in various formats, such as JUnit XML, TAP, and more, which can be used for continuous integration and other reporting purposes.
JUnit XML Reporter
The JUnit XML Reporter generates test results in JUnit XML format, which is commonly used by CI tools like Jenkins. The code sample demonstrates how to configure and add the JUnit XML Reporter to a Jasmine test suite.
const Jasmine = require('jasmine');
const JasmineReporters = require('jasmine-reporters');
const jasmine = new Jasmine();
jasmine.loadConfigFile('spec/support/jasmine.json');
const junitReporter = new JasmineReporters.JUnitXmlReporter({
savePath: 'test_results',
consolidateAll: false
});
jasmine.addReporter(junitReporter);
jasmine.execute();
TAP Reporter
The TAP Reporter outputs test results in the Test Anything Protocol (TAP) format. This format is useful for integrating with TAP consumers. The code sample shows how to set up the TAP Reporter in a Jasmine test suite.
const Jasmine = require('jasmine');
const JasmineReporters = require('jasmine-reporters');
const jasmine = new Jasmine();
jasmine.loadConfigFile('spec/support/jasmine.json');
const tapReporter = new JasmineReporters.TapReporter();
jasmine.addReporter(tapReporter);
jasmine.execute();
TeamCity Reporter
The TeamCity Reporter formats test results for integration with JetBrains TeamCity. The code sample illustrates how to add the TeamCity Reporter to a Jasmine test suite.
const Jasmine = require('jasmine');
const JasmineReporters = require('jasmine-reporters');
const jasmine = new Jasmine();
jasmine.loadConfigFile('spec/support/jasmine.json');
const teamCityReporter = new JasmineReporters.TeamCityReporter();
jasmine.addReporter(teamCityReporter);
jasmine.execute();
The karma-junit-reporter package is a reporter for the Karma test runner that generates test results in JUnit XML format. It is similar to the JUnit XML Reporter in jasmine-reporters but is specifically designed for use with Karma.
The mocha-junit-reporter package is a reporter for the Mocha testing framework that outputs test results in JUnit XML format. It serves a similar purpose to the JUnit XML Reporter in jasmine-reporters but is tailored for Mocha.
The jest-junit package is a Jest reporter that generates test results in JUnit XML format. It is comparable to the JUnit XML Reporter in jasmine-reporters but is intended for use with the Jest testing framework.
This branch is for Jasmine 2.x. Switch to the 1.x branch.
Jasmine Reporters is a collection of javascript jasmine reporter classes that can be used with the JasmineBDD testing framework.
Included reporters:
Should work with all modern versions of Phantom JS, and has been tested with PhantomJS 1.4.6 through 1.9.6 on Mac OS X. If you find issues with a particular version, please consider creating a pull request.
The reporters also work in Node.js, and most can be used in combination with jasmine-node. Make sure to use the correct combination of jasmine-reporters and jasmine-node, as both projects have different versions / branches for Jasmine1.x vs Jasmine2.x support.
When used for in-browser tests, the reporters are registered on a jasmineReporters
object in the
global scope (i.e. window.jasmineReporters
).
var junitReporter = new jasmineReporters.JUnitXmlReporter({
savePath: '..',
consolidateAll: false
});
jasmine.getEnv().addReporter(junitReporter);
In order to write files to the local filesystem for in-browser tests, the reporters will attempt
to use PhantomJS to create the files. A special method __phantom_writeFile
is injected by the
included phantomjs.runner.sh
script.
It is strongly recommended to use the provided script to run your test suite using PhantomJS. If
you want to use your own PhantomJS runner, you will need to inject a __phantom_writeFile
method, and also take care to correctly determine when all results have been reported.
You can use the included PhantomJS test runner to run any of the included examples.
NOTE: you will need to install the Jasmine dependency via bower
if you want to use the
included PhantomJS runner for any of the included examples--this is where the examples
look for the Jasmine core library.
# install jasmine via bower
bower install
# run any of the examples
bin/phantomjs.runner.sh examples/tap_reporter.html
bin/phantomjs.runner.sh examples/junit_xml_reporter.html
In Node.js, jasmine-reporters exports an object with all the reporters which you can use however you like.
var reporters = require('jasmine-reporters');
var junitReporter = new reporters.JUnitXmlReporter({
savePath: __dirname,
consolidateAll: false
});
jasmine.getEnv().addReporter(junitReporter)
An example for each reporter is available in the examples
directory.
jasmine-reporters is built for Jasmine 2.x. If you are still using Jasmine 1.x, please use the correct tag / branch / npm version:
bower install jasmine-reporters#^1.0.0
npm install jasmine-reporters@^1.0.0
git submodule add -b jasmine1.x git@github.com:larrymyers/jasmine-reporters.git jasmine-reporters
1.*
tagsjasmine
object
new jasmine.JUnitXmlReporter( /* ... */ );
new jasmineReporters.JUnitXmlReporter( /* ... */ );
new jasmine.JUnitXmlReporter('testresults', true, true, 'junit-', true);
new jasmineReporters.JUnitXmlReporter({savePath:'testresults', filePrefix: 'junit-', consolidateAll:true});
As of Protractor 1.6.0, protractor supports Jasmine 2 by specifying
framework: "jasmine2"
in your protractor.conf file.
First, install a Jasmine 2.x-compatible of jasmine-reporters:
npm install --save-dev jasmine-reporters@^2.0.0
Then set everything up inside your protractor.conf:
framework: 'jasmine2',
onPrepare: function() {
var jasmineReporters = require('jasmine-reporters');
jasmine.getEnv().addReporter(new jasmineReporters.JUnitXmlReporter({
consolidateAll: true,
savePath: 'testresults',
filePrefix: 'xmloutput'
}));
}
If you run a multiCapabilities
setup you can reflect this in your test results
by using the option modifySuiteName
. This enables you to have distinct suite
names per capability.
multiCapabilities: [
{browserName: 'firefox'},
{browserName: 'chrome'}
],
framework: 'jasmine2',
onPrepare: function() {
var jasmineReporters = require('jasmine-reporters');
// returning the promise makes protractor wait for the reporter config before executing tests
return browser.getProcessedConfig().then(function(config) {
// you could use other properties here if you want, such as platform and version
var browserName = config.capabilities.browserName;
var junitReporter = new jasmineReporters.JUnitXmlReporter({
consolidateAll: true,
savePath: 'testresults',
// this will produce distinct xml files for each capability
filePrefix: browserName + '-xmloutput',
modifySuiteName: function(generatedSuiteName, suite) {
// this will produce distinct suite names for each capability,
// e.g. 'firefox.login tests' and 'chrome.login tests'
return browserName + '.' + generatedSuiteName;
}
});
jasmine.getEnv().addReporter(junitReporter);
});
}
You can also use the modifyReportFileName
option to generate distinct
filenames when consolidateAll
is false
.
multiCapabilities: [
{browserName: 'firefox'},
{browserName: 'chrome'}
],
framework: 'jasmine2',
onPrepare: function() {
var jasmineReporters = require('jasmine-reporters');
// returning the promise makes protractor wait for the reporter config before executing tests
return browser.getProcessedConfig().then(function(config) {
// you could use other properties here if you want, such as platform and version
var browserName = config.capabilities.browserName;
var junitReporter = new jasmineReporters.JUnitXmlReporter({
consolidateAll: false,
savePath: 'testresults',
modifyReportFileName: function(generatedFileName, suite) {
// this will produce distinct file names for each capability,
// e.g. 'firefox.SuiteName' and 'chrome.SuiteName'
return browserName + '.' + generatedFileName;
}
});
jasmine.getEnv().addReporter(junitReporter);
});
}
FAQs
Reporters for the Jasmine BDD Framework
The npm package jasmine-reporters receives a total of 228,519 weekly downloads. As such, jasmine-reporters popularity was classified as popular.
We found that jasmine-reporters demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.