Allure reporter for Mocha
Assuming that you have mocha installed, install reporter via npm:
npm install mocha-allure-reporter
Then use it as any other mocha reporter:
mocha --reporter mocha-allure-reporter
After running tests you will get raw tests result into
See generator list
on how to make a report from raw results.
Also check out mocha-allure-example to see it in action.
- targetDir (string) – directory where test results will be stored
Allure is a test framework which provides more data from tests than usual. Once added
mocha-allure-reporter will create global
allure object with the following API:
allure.createStep(name, stepFn)– define step function. Result of each call of this function will be recorded into report.
allure.createAttachement(name, content, [type])– save attachment to test. If you're calling this inside step function or during its execution (e.g. asynchronously via promises), attachment will be saved to step function.
name(String) - attachment name. Note that it is not then name of the file, actual filename will be generated.
content(Buffer|String|Function) – attachment content. If you pass Buffer or String, it will be saved to file immediately. If you are passing Function, you will get decorated function and you can call it several times to trigger attachment. General purpose of the second case is an ability to create utility function to take screenshot. You can define function for you test framework only once and then call it each time you need a screenshot.
type(String, optional) – attachment MIME-type. If you omit this argument we'll try to detect type automatically via file-type library
allure.description(description)– set detailed test description, if test name is not enough.
allure.severity(severity)– set test severity, one of:
trivial. You can also use constants like
allure.feature(featureName)– assign feature to test
allure.story(storyName)– assign user story to test. See documentation for details
allure.addEnvironment(name, value)- save environment value. It is similar to
addArgumentmethod, but it is designed to store more verbose data, like HTTP-links to test page or used package version.