Security News
NIST Misses 2024 Deadline to Clear NVD Backlog
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
jest-allure2-adapter
Advanced tools
Originally forked from jest-allure.
Allure Framework is a flexible lightweight multi-language test report tool that not only shows a very concise representation of what have been tested in a neat web report form, but allows everyone participating in the development process to extract maximum of useful information from everyday execution of tests.
yarn add -D jest-allure2-adapter
or
npm install --save-dev jest-allure2-adapter
Then add jest-allure2-adapter/dist/setup-default
to setupFilesAfterEnv
section of your config.
setupFilesAfterEnv: ["jest-allure2-adapter/dist/setup-default"]
reporters: ["default", "jest-allure2-adapter"],
Run tests. Results will be generated and stored in allure-results
folder.
You need to install the CLI in order to obtain a report.
For example see allure-commandline.
To see a report in browser, run in console
allure serve
If you want to generate html version, run in console
allure generate
You can add description, screenshots, steps, severity and lots of other fancy stuff to your reports.
Global variable reporter
available in your tests with such methods:
description(description: string): this;
descriptionHtml(description: string): this;
severity(severity: Severity): this;
epic(epic: string): this;
feature(feature: string): this;
story(story: string): this;
owner(story: string): this;
step<T>(name: string, body: () => any): T;
startStep(name: string): this;
endStep(status?: Status): this;
addEnvironment(name: string, value: string): this;
addAttachment(name: string, buffer: any, type: string): this;
addTestAttachment(name: string, buffer: any, type: string): this;
addLabel(name: string, value: string): this;
addParameter(paramName: string, name: string, value: string): this;
addParameters(...params: [string, any][]): this;
addLink(options: {
name?: string;
url: string;
type?: LinkType;
}): this;
addIssue(options: {
id: string;
name?: string;
url?: string;
}): this;
addTms(options: {
id: string;
name?: string;
url?: string;
}): this;
To use custom jasmine reporter - for example to add smth into allure when spec or suite started you can use custom jasmine reporter.
In this case you do NOT need to add jest-allure2-adapter/dist/setup-default
into SetupFilesAfterEnv section.
Just call registerAllureReporter with yur custom jasmine reporter.
see example:
// jest.setup.ts
...
setupFilesAfterEnv: [
'./config/jest-custom-reporter.ts',
],
...
// jest-custom-reporter.ts
import {
AllureReporterApi,
jasmine_,
registerAllureReporter,
} from 'jest-allure2-adapter';
class JasmineAllureReporter implements jasmine_.CustomReporter {
private allure: AllureReporterApi;
constructor(allure: AllureReporterApi) {
this.allure = allure;
}
suiteStarted(suite?: jasmine_.CustomReporterResult) {
this.allure.startGroup(suite.description);
// some actions here on suite started
}
suiteDone() {
// some actions here on suite end
this.allure.endGroup();
}
specStarted(spec: jasmine_.CustomReporterResult) {
this.allure.startTest(spec);
// some actions here on test started
}
specDone(spec: jasmine_.CustomReporterResult) {
// some actions here on spec end
this.allure.endTest(spec);
}
}
registerAllureReporter((allure) => new JasmineAllureReporter(allure));
Example (todo)
import { Severity } from "jest-allure/dist/Reporter";
import { Feature } from "somwhere in your project";
describe("Fancy test", () => {
...
it("Test your amazing feature", async () => {
reporter
.description("Feature should work cool")
.severity(Severity.Critical)
.feature(Feature.Betting)
.story("BOND-007");
reporter.startStep("Check it's fancy");
// expect that it's fancy
reporter.endStep();
reporter.startStep("Check it's cool");
// expect that it's cool
reporter.endStep();
const screenshotBuffer = await page.screenshot();
reporter.addAttachment("Screenshot", screenshotBuffer, "image/png");
});
...
}
);
jest-allure2-adapter
reporter dynamically configure "setupTestFrameworkScriptFile" option in Jest configuration.
If you have your own setupTestFrameworkScriptFile file, you need to manually register allure reporter, for it you need to import jest-allure/dist/setup-default.
import 'jest-allure2-adapter/dist/setup-default';
In case if you have jest version > 24 just add jest-allure/dist/setup-default
to setupFilesAfterEnv
section of your config.
0.2.23 default and custom reporter, timestamps in steps
Taisia Pitko |
---|
FAQs
Allure 2 Adapter for jest
The npm package jest-allure2-adapter receives a total of 4,387 weekly downloads. As such, jest-allure2-adapter popularity was classified as popular.
We found that jest-allure2-adapter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.