New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

allure-playwright

Package Overview
Dependencies
Maintainers
3
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

allure-playwright - npm Package Compare versions

Comparing version 2.0.0-beta.26 to 2.0.0

dist/testplan.d.ts

16

dist/helpers.d.ts
import { Label, Link, MetadataMessage, ParameterOptions } from "allure-js-commons";
export declare class allure {
static addMetadataAttachment(metadata: MetadataMessage): void;
static label(label: Label | Label[]): void;
static label(label: string, value: string): void;
static labels(...values: Label[]): void;
static description(value: string): void;
static link(link: Link): void;
static link(url: string, name?: string, type?: string): void;
static links(...values: Link[]): void;
static id(id: string): void;

@@ -14,10 +16,12 @@ static epic(epic: string): void;

static layer(layerName: string): void;
static addParameter(name: string, value: string, options?: ParameterOptions): void;
static subSuite(name: string): void;
static owner(owner: string): void;
static severity(severity: string): void;
static tag(...tags: string[]): void;
static issue(issueData: Omit<Link, "type">): void;
static tms(issueData: Omit<Link, "type">): void;
static tag(tag: string): void;
static tags(...values: string[]): void;
static issue(name: string, url: string): void;
static tms(name: string, url: string): void;
static parameter(name: string, value: string, options?: ParameterOptions): void;
static addParameter(name: string, value: string, options?: ParameterOptions): void;
}
export { LabelName } from "allure-js-commons";

@@ -17,7 +17,10 @@ "use strict";

}
static label(label) {
static label(label, value) {
this.addMetadataAttachment({
labels: Array.isArray(label) ? label : [label],
labels: [{ name: label, value }],
});
}
static labels(...values) {
values.forEach(({ name, value }) => this.label(name, value));
}
static description(value) {

@@ -28,97 +31,63 @@ this.addMetadataAttachment({

}
static link(link) {
static link(url, name, type) {
this.addMetadataAttachment({
links: Array.isArray(link) ? link : [link],
links: [{ url, name, type }],
});
}
static links(...values) {
values.forEach(({ url, name, type }) => this.link(url, name, type));
}
static id(id) {
this.label({
value: id,
name: allure_js_commons_1.LabelName.AS_ID,
});
this.label(allure_js_commons_1.LabelName.ALLURE_ID, id);
}
static epic(epic) {
this.label({
name: allure_js_commons_1.LabelName.EPIC,
value: epic,
});
this.label(allure_js_commons_1.LabelName.EPIC, epic);
}
static feature(epic) {
this.label({
name: allure_js_commons_1.LabelName.FEATURE,
value: epic,
});
this.label(allure_js_commons_1.LabelName.FEATURE, epic);
}
static story(story) {
this.label({
name: allure_js_commons_1.LabelName.STORY,
value: story,
});
this.label(allure_js_commons_1.LabelName.STORY, story);
}
static suite(name) {
this.label({
name: allure_js_commons_1.LabelName.SUITE,
value: name,
});
this.label(allure_js_commons_1.LabelName.SUITE, name);
}
static parentSuite(name) {
this.label({
name: allure_js_commons_1.LabelName.PARENT_SUITE,
value: name,
});
this.label(allure_js_commons_1.LabelName.PARENT_SUITE, name);
}
static layer(layerName) {
this.label({
name: allure_js_commons_1.LabelName.LAYER,
value: layerName,
});
this.label(allure_js_commons_1.LabelName.LAYER, layerName);
}
static addParameter(name, value, options) {
this.addMetadataAttachment({
parameter: [
Object.assign({ name,
value }, options),
],
});
}
static subSuite(name) {
this.label({
name: allure_js_commons_1.LabelName.SUB_SUITE,
value: name,
});
this.label(allure_js_commons_1.LabelName.SUB_SUITE, name);
}
static owner(owner) {
this.label({
name: allure_js_commons_1.LabelName.OWNER,
value: owner,
});
this.label(allure_js_commons_1.LabelName.OWNER, owner);
}
static severity(severity) {
this.label({
name: allure_js_commons_1.LabelName.SEVERITY,
value: severity,
});
this.label(allure_js_commons_1.LabelName.SEVERITY, severity);
}
static tag(...tags) {
for (const tag of tags) {
this.label({
name: allure_js_commons_1.LabelName.TAG,
value: tag,
});
}
static tag(tag) {
this.label(allure_js_commons_1.LabelName.TAG, tag);
}
static issue(issueData) {
this.link({
url: issueData.url,
name: issueData.name,
type: allure_js_commons_1.LinkType.ISSUE,
});
static tags(...values) {
values.forEach((value) => this.tag(value));
}
static tms(issueData) {
this.link({
url: issueData.url,
name: issueData.name,
type: allure_js_commons_1.LinkType.TMS,
static issue(name, url) {
this.link(url, name, allure_js_commons_1.LinkType.ISSUE);
}
static tms(name, url) {
this.link(url, name, allure_js_commons_1.LinkType.TMS);
}
static parameter(name, value, options) {
this.addMetadataAttachment({
parameter: [
Object.assign({ name,
value }, options),
],
});
}
static addParameter(name, value, options) {
this.parameter(name, value, options);
}
}

@@ -125,0 +94,0 @@ exports.allure = allure;

@@ -22,2 +22,4 @@ import { FullConfig } from "@playwright/test";

private hostname;
private globalStartTime;
private processedDiffs;
constructor(options?: AllureReporterOptions);

@@ -28,3 +30,4 @@ onBegin(config: FullConfig, suite: Suite): void;

onStepEnd(_test: TestCase, _result: TestResult, step: TestStep): void;
onTestEnd(test: TestCase, result: TestResult): void;
onTestEnd(test: TestCase, result: TestResult): Promise<void>;
addSkippedResults(): void;
onEnd(): void;

@@ -31,0 +34,0 @@ private getAllureRuntime;

@@ -31,2 +31,4 @@ "use strict";

this.hostname = process_1.default.env.ALLURE_HOST_NAME || os_1.default.hostname();
this.globalStartTime = new Date();
this.processedDiffs = [];
this.options = options;

@@ -70,5 +72,7 @@ }

.join("/");
const fullName = `${relativeFile}#${test.title}`;
const nameSuites = suiteTitles.length > 0 ? `${suiteTitles.join(" ")} ` : "";
const fullName = `${relativeFile}#${nameSuites}${test.title}`;
const testCaseIdSource = `${relativeFile}#${test.title}`;
allureTest.fullName = fullName;
allureTest.testCaseId = (0, allure_js_commons_1.md5)(fullName);
allureTest.testCaseId = (0, allure_js_commons_1.md5)(testCaseIdSource);
allureTest.historyId = (0, allure_js_commons_1.md5)(`${fullName}${project.name || ""}`);

@@ -98,4 +102,4 @@ this.allureTestCache.set(test, allureTest);

}
onTestEnd(test, result) {
var _a, _b, _c;
async onTestEnd(test, result) {
var _a, _b, _c, _d;
const runtime = this.getAllureRuntime();

@@ -135,4 +139,4 @@ const allureTest = this.allureTestCache.get(test);

(_c = metadata.parameter) === null || _c === void 0 ? void 0 : _c.forEach((val) => allureTest.addParameter(val.name, val.value, {
hidden: val.hidden,
excluded: val.excluded,
mode: val.mode,
}));

@@ -154,11 +158,19 @@ if (metadata.description) {

}
if (attachment.name.endsWith("-expected.png")) {
allureTest.addAttachment("expected", attachment.contentType, fileName);
const diffEndRegexp = /-((expected)|(diff)|(actual))\.png$/;
if (attachment.name.match(diffEndRegexp)) {
const pathWithoutEnd = attachment.path.replace(diffEndRegexp, "");
if (this.processedDiffs.includes(pathWithoutEnd)) {
continue;
}
const actualBase64 = await (0, allure_js_commons_1.readImageAsBase64)(`${pathWithoutEnd}-actual.png`), expectedBase64 = await (0, allure_js_commons_1.readImageAsBase64)(`${pathWithoutEnd}-expected.png`), diffBase64 = await (0, allure_js_commons_1.readImageAsBase64)(`${pathWithoutEnd}-diff.png`);
const diffName = attachment.name.replace(diffEndRegexp, "");
const res = (_d = this.allureRuntime) === null || _d === void 0 ? void 0 : _d.writeAttachment(JSON.stringify({
expected: expectedBase64,
actual: actualBase64,
diff: diffBase64,
name: diffName,
}), { contentType: internal_1.ALLURE_IMAGEDIFF_CONTENT_TYPE, fileExtension: "imagediff" });
allureTest.addAttachment(diffName, { contentType: internal_1.ALLURE_IMAGEDIFF_CONTENT_TYPE }, res);
this.processedDiffs.push(pathWithoutEnd);
}
else if (attachment.name.endsWith("-actual.png")) {
allureTest.addAttachment("actual", attachment.contentType, fileName);
}
else if (attachment.name.endsWith("-diff.png")) {
allureTest.addAttachment("diff", attachment.contentType, fileName);
}
else {

@@ -179,3 +191,31 @@ allureTest.addAttachment(attachment.name, attachment.contentType, fileName);

}
addSkippedResults() {
const unprocessedCases = this.suite
.allTests()
.filter((testCase) => !this.allureTestCache.has(testCase));
unprocessedCases.forEach((testCase) => {
this.onTestBegin(testCase);
const allureTest = this.allureTestCache.get(testCase);
if (allureTest) {
allureTest.addLabel(allure_js_commons_1.LabelName.ALLURE_ID, "-1");
allureTest.detailsMessage =
"This test was skipped due to test setup error. Check you setup scripts to fix the issue.";
}
this.onTestEnd(testCase, {
status: allure_js_commons_1.Status.SKIPPED,
attachments: [],
duration: 0,
errors: [],
parallelIndex: 0,
workerIndex: 0,
retry: 0,
steps: [],
stderr: [],
stdout: [],
startTime: this.globalStartTime,
});
});
}
onEnd() {
this.addSkippedResults();
for (const group of this.allureGroupCache.values()) {

@@ -182,0 +222,0 @@ group.endGroup();

{
"name": "allure-playwright",
"version": "2.0.0-beta.26",
"version": "2.0.0",
"description": "Allure Playwright integration",
"license": "Apache-2.0",
"author": {
"name": "Microsoft Corporation"
"name": "Qameta Software",
"email": "allure@qameta.io",
"url": "https://qameta.io/"
},

@@ -35,3 +37,3 @@ "repository": {

"dependencies": {
"allure-js-commons": "2.0.0-beta.26"
"allure-js-commons": "2.0.0"
},

@@ -38,0 +40,0 @@ "files": [

@@ -151,6 +151,6 @@ # allure-playwright

import { test, expect } from "@playwright/test";
import { allure, LabelName } from "allure-playwright";
import { allure } from "allure-playwright";
test("basic test", async ({ page }, testInfo) => {
allure.label({ name: LabelName.LANGUAGE, value: "typescript" });
allure.label("labelName", "labelValue");
});

@@ -166,7 +166,4 @@ ```

test("basic test", async ({ page }, testInfo) => {
allure.link({ url: "https://playwright.dev", name: "playwright-site" });
allure.issue({
url: "https://github.com/allure-framework/allure-js/issues/352",
name: "Target issue",
});
allure.link("https://playwright.dev", "playwright-site"); // link with name
allure.issue("Issue Name", "https://github.com/allure-framework/allure-js/issues/352");
});

@@ -182,3 +179,3 @@ ```

test("basic test", async ({ page }, testInfo) => {
allure.id("Some id");
allure.id("420");
});

@@ -266,8 +263,9 @@ ```

test("basic test", async ({ page }, testInfo) => {
allure.addParameter("parameterName", "parameterValue");
allure.parameter("parameterName", "parameterValue");
});
```
Also addParameter takes an third optional parameter with the hidden and excluded options:
`hidden: true` - hides parameter from the report
Also parameter takes an third optional parameter with the hidden and excluded options:
`mode: "hidden" | "masked"` - `masked` hide parameter value to secure sensitive data, and `hidden` entirely hide parameter from report
`excluded: true` - excludes parameter from the history

@@ -280,4 +278,67 @@

test("basic test", async ({ page }, testInfo) => {
allure.addParameter("parameterName", "parameterValue", { hidden: true, excluded: true });
allure.addParameter("parameterName", "parameterValue", { mode: "masked", excluded: true });
});
```
### Selective test execution
Allure allow you to execute only a subset of tests. This is useful when you want to run only a specific test or a group of tests.
To enable this feature, you need to add the following code to your `playwright.config.js`:
```diff
+ import { testPlanFilter } from "allure-playwright/dist/testplan";
export default {
reporter: [
[
"allure-playwright",
],
],
projects: [
{
name: "chromium",
},
],
+ grep: testPlanFilter()
};
```
Allure will read `ALLURE_TESTPLAN_PATH` environment variable and read testplan from the specified file.
### EnvironmentInfo usage
Allure allows you to add environment information to the report. This is useful when you want to add some additional information to the report.
to enable this feature, you need to add the following field to your `playwright.config.js`:
```diff
export default {
reporter: [
[
"allure-playwright",
{
+ environmentInfo: {
+ E2E_NODE_VERSION: process.version,
+ E2E_OS: process.platform,
+ },
},
],
],
};
```
### Visual comparisons usage
Allure allows you to add visual comparisons to the report. This is useful when you want to add some additional information to the report.
```ts
import { test, expect } from "@playwright/test";
test("screendiff", async ({ page }) => {
await page.goto("https://playwright.dev/");
await expect(page).toHaveScreenshot();
});
```
If screenshots don't match, the report shows difference between them.
![screendiff-preview](./docs/screendiff.jpg)

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc