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 3.0.0-beta.7 to 3.0.0-beta.8

4

dist/cjs/index.js

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

var diffEndRegexp = /-((expected)|(diff)|(actual))\.png$/;
// 12 (allureattach) + 1 (_) + 36 (uuid v4) + 1 (_)
var stepAttachPrefixLength = 50;
var AllureReporter = exports.AllureReporter = /*#__PURE__*/function () {

@@ -237,3 +235,3 @@ function AllureReporter(config) {

this.allureRuntime.startStep(testUuid, undefined, {
name: step.title.substring(0, stepAttachPrefixLength),
name: step.title,
start: step.startTime.getTime()

@@ -240,0 +238,0 @@ });

@@ -35,4 +35,2 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }

var diffEndRegexp = /-((expected)|(diff)|(actual))\.png$/;
// 12 (allureattach) + 1 (_) + 36 (uuid v4) + 1 (_)
var stepAttachPrefixLength = 50;
export var AllureReporter = /*#__PURE__*/function () {

@@ -218,3 +216,3 @@ function AllureReporter(config) {

this.allureRuntime.startStep(testUuid, undefined, {
name: step.title.substring(0, stepAttachPrefixLength),
name: step.title,
start: step.startTime.getTime()

@@ -221,0 +219,0 @@ });

{
"name": "allure-playwright",
"version": "3.0.0-beta.7",
"version": "3.0.0-beta.8",
"description": "Allure Playwright integration",

@@ -58,3 +58,3 @@ "keywords": [

"dependencies": {
"allure-js-commons": "3.0.0-beta.7"
"allure-js-commons": "3.0.0-beta.8"
},

@@ -68,15 +68,16 @@ "devDependencies": {

"@playwright/test": "^1.45.1",
"@stylistic/eslint-plugin": "^2.6.1",
"@types/babel__core": "^7",
"@types/babel__preset-env": "^7",
"@types/eslint": "^8",
"@types/eslint": "^8.56.11",
"@types/node": "^20.14.2",
"@typescript-eslint/eslint-plugin": "^7.0.0",
"@typescript-eslint/parser": "^7.0.0",
"@typescript-eslint/eslint-plugin": "^8.0.0",
"@typescript-eslint/parser": "^8.0.0",
"allure-commandline": "^2.29.0",
"allure-vitest": "3.0.0-beta.7",
"allure-vitest": "3.0.0-beta.8",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-jsdoc": "^48.0.0",
"eslint-plugin-n": "^17.0.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jsdoc": "^48.11.0",
"eslint-plugin-n": "^17.10.1",
"eslint-plugin-no-null": "^1.0.2",

@@ -83,0 +84,0 @@ "eslint-plugin-prefer-arrow": "^1.2.3",

@@ -8,19 +8,7 @@ # allure-playwright

- Learn more about Allure Report at https://allurereport.org
- ๐Ÿ“š [Documentation](https://allurereport.org/docs/) โ€“ discover official documentation for Allure
Report
-
- ๐Ÿ“š [Documentation](https://allurereport.org/docs/) โ€“ discover official documentation for Allure Report
- โ“ [Questions and Support](https://github.com/orgs/allure-framework/discussions/categories/questions-support) โ€“ get help from the team and community
- ๐Ÿ“ข [Official annoucements](https://github.com/orgs/allure-framework/discussions/categories/announcements) โ€“ be in touch with the latest updates
- ๐Ÿ’ฌ [General Discussion ](https://github.com/orgs/allure-framework/discussions/categories/general-discussion) โ€“ engage in casual conversations, share insights and ideas with the community
โ“ [Questions and Support](https://github.com/orgs/allure-framework/discussions/categories/questions-support) โ€“
get help from the team and community
-
๐Ÿ“ข [Official annoucements](https://github.com/orgs/allure-framework/discussions/categories/announcements) โ€“
be in touch with the latest updates
-
๐Ÿ’ฌ [General Discussion ](https://github.com/orgs/allure-framework/discussions/categories/general-discussion) โ€“
engage in casual conversations, share insights and ideas with the community
---

@@ -38,19 +26,23 @@

Just add `allure-playwright` into Playwright configuration file:
Add `allure-playwright` as the reporter in the Playwright configuration file:
```js
module.exports = {
import { defineConfig } from '@playwright/test';
export default defineConfig({
reporter: "allure-playwright",
}
});
```
Or use the reporter with another ones:
Or, if you want to use more than one reporter:
```js
module.exports = {
reporter: [["line"], ["allure-playwright"]];
}
import { defineConfig } from '@playwright/test';
export default defineConfig({
reporter: [["line"], ["allure-playwright"]],
});
```
Or pass the same value via command line:
Or pass the same values via the command line:

@@ -61,21 +53,15 @@ ```bash

Specify location for allure results:
When the test run completes, the result files will be generated in the `./allure-results`
directory. If you want to use another location, provide it via the `resultsDir`
reporter option ([see below](#allure-playwright-options)).
Mac / Linux
### View the report
```bash
ALLURE_RESULTS_DIR=my-allure-results npx playwright test --reporter=line,allure-playwright
```
> [!NOTE]
> You need Allure Report to generate and open the report from the result files. See the [installation instructions](https://allurereport.org/docs/install/) for more details.
Windows
```bash
set ALLURE_RESULTS_DIR=my-allure-results
npx playwright test --reporter=line,allure-playwright
```
Generate Allure Report:
```bash
allure generate my-allure-results -o allure-report --clean
allure generate ./allure-results -o ./allure-report
```

@@ -86,117 +72,30 @@

```bash
allure open allure-report
allure open ./allure-report
```
## Reporter options
## The documentation
Some reporter settings can set by following options:
Learn more about Allure Playwright from the official documentation at
[https://allurereport.org/docs/playwright/](https://allurereport.org/docs/playwright/).
| Option | Description | Default |
|--------------|------------------------------------------------------------------------------|--------------------|
| outputFolder | Path to results folder. | `./allure-results` |
| detail | Hide `pw:api` and `hooks` steps in report. [See below](#hooks-and-api-calls) | `true` |
| suiteTitle | Use test title instead of `allure.suite()`. [See below](#suit-title) | `true` |
| links | Allure Runtime API links templates. [See below](#links-usage) | `undefined` |
## Allure Playwright options
### Options Usage
Use following options to configure Allure Playwright:
```js
module.exports = {
reporter: [
[
"allure-playwright",
{
detail: true,
outputFolder: "my-allure-results",
suiteTitle: false,
},
],
],
};
```
| Option | Description | Default |
|-----------------|----------------------------------------------------------------------------------------------------------------------|--------------------|
| resultsDir | The path of the results folder. | `./allure-results` |
| detail | Hide the `pw:api` and `hooks` steps in report. | `true` |
| suiteTitle | Use test title instead of `allure.suite()`. | `true` |
| links | Allure Runtime API link templates. | `undefined` |
| environmentInfo | A set of key-value pairs to display in the Environment section of the report | `undefined` |
| categories | An array of category definitions, each describing a [category of defects](https://allurereport.org/docs/categories/) | `undefined` |
### Options for Allure TestOps compatibility
Here is an example of the reporter configuration:
After exporting test results into Allure TestOps, the results may contain extra steps with
Playwrightโ€™s API calls, as
well as collisions in the name of the suits.
#### Hooks and API calls
By default, each step of the `test.step()` functions contains subsections Playwrightโ€™s API methods
calls.
The report looks like:
```text
> Before Hooks
> browserContext.newPage
> Open example.com
> page.goto( https://example.com/)
> Expect page text
> expect.toBeVisible
> After Hooks
> browserContext.close
```
To hide steps with `Before / After hooks` and API calls `page / expect / browser` set the
option `detail: false`
#### Suite title
By default, the reporter uses the test file path as the suite name.
If tests uses the `allure.suite()` and it's value must be used in Allure TestOps custom fields, then
set the option `suiteTitle: false`
## Providing extra information
Tests extra information can be provided by labels:
- label
- link
- id
- epic
- feature
- story
- suite
- parentSuite
- subSuite
- owner
- severity
- tag
- issue
- tms
### Labels Usage
```js
import { test, expect } from "@playwright/test";
import { label } from "allure-js-commons";
import { defineConfig } from '@playwright/test';
import os from "node:os";
test("basic test", async ({page}, testInfo) => {
await label("labelName", "labelValue");
});
```
### Links Usage
```js
import { test, expect } from "@playwright/test";
import { link, issue } from "allure-js-commons";
test("basic test", async ({ page }, testInfo) => {
await link("https://playwright.dev", "link-type", "playwright-site"); // link with name and type
await issue("Issue Name", "https://github.com/allure-framework/allure-js/issues/352");
});
```
You can also configure links formatters to make usage much more convenient. `%s`
in `urlTemplate` parameter will be replaced by given value.
```diff
module.exports = {
export default defineConfig({
reporter: [

@@ -207,240 +106,30 @@ [

detail: true,
outputFolder: "my-allure-results",
+ links: [
+ {
+ type: "issue",
+ urlTemplate: "https://example.org/issues/%s",
+ nameTemplate: "Issue: %s",
+ },
+ {
+ type: "tms",
+ urlTemplate: "https://example.org/tasks/%s"
+ },
+ {
+ type: "custom",
+ urlTemplate: "https://example.org/custom/%s"
+ },
+ ]
resultsDir: "my-allure-results",
suiteTitle: false,
links: {
link: {
urlTemplate: "https://github.com/allure-framework/allure-js/blob/main/%s",
},
issue: {
urlTemplate: "https://github.com/allure-framework/allure-js/issues/%s",
nameTemplate: "ISSUE-%s",
},
},
environmentInfo: {
OS: os.platform(),
Architecture: os.arch(),
NodeVersion: process.version,
},
categories: [
{
name: "Missing file errors",
messageRegex: /^ENOENT: no such file or directory/,
},
],
},
],
],
};
```
Then you can assign link using shorter notation:
```js
import {test, expect} from "@playwright/test";
import {issue, tms, link} from "allure-js-commons";
test("basic test", async () => {
await issue("Issue Name", "352");
await tms("Task Name", "352");
await link("352", "Link name", "custom");
});
```
### Id Usage
```js
import {test, expect} from "@playwright/test";
import {allure, LabelName} from "allure-playwright";
test("basic test", async ({page}, testInfo) => {
await allure.id("420");
});
```
### Epics Usage
```js
import {test, expect} from "@playwright/test";
import {allure} from "allure-playwright";
test("basic test", async ({page}, testInfo) => {
await allure.epic("Some Epic");
});
```
### Stories Usage
```js
import {test, expect} from "@playwright/test";
import {allure} from "allure-playwright";
test("basic test", async ({page}, testInfo) => {
await allure.story("Some Story");
});
```
### Screenshot usage
```ts
import {test, expect} from "@playwright/test";
import {allure} from "allure-playwright";
test("basic test", async ({page}, testInfo) => {
await allure.attachment("basic-page-screen", await page.screenshot(), {
contentType: "image/png",
});
});
```
### Attachments Usage
```js
import {test, expect} from "@playwright/test";
import {allure} from "allure-playwright";
export const TODO_ITEMS = ["buy some cheese", "feed the cat", "book a doctors appointment"];
test("basic test", async ({page}, testInfo) => {
await allure.attachment("TODO_ITEMS", JSON.stringify(TODO_ITEMS), {
contentType: "application/json",
});
});
```
### Steps usage
```ts
import {test, expect} from "@playwright/test";
import {allure} from "allure-playwright";
export const TODO_ITEMS = ["buy some cheese", "feed the cat", "book a doctors appointment"];
test("basic test", async ({page}, testInfo) => {
await allure.step("Visit todolist page", async () => {
await page.goto("https://demo.playwright.dev/todomvc");
});
await allure.step("Create 1st todo.", async () => {
await page.locator(".new-todo").fill(TODO_ITEMS[0]);
await page.locator(".new-todo").press("Enter");
});
await expect(
page.locator(".view label"),
"Make sure the list only has one todo item.",
).toHaveText([TODO_ITEMS[0]]);
});
```
### Parameters usage
```ts
import {test, expect} from "@playwright/test";
import {allure} from "allure-playwright";
test("basic test", async ({page}, testInfo) => {
await allure.parameter("parameterName", "parameterValue");
});
```
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
```ts
import {test, expect} from "@playwright/test";
import {allure} from "allure-playwright";
test("basic test", async ({page}, testInfo) => {
await allure.parameter("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)
### Passing metadata from test title
You also can pass allure metadata from test title.
This is useful when you need to set allureId for the tests with failing before hooks. Just
add `@allure.id={idValue}` for the allureId or `@allure.label.{labelName}={labelValue}` for other
types of labels.
```ts
import {test, expect} from "@playwright/test";
test("test with allureId @allure.id=256", async ({}) => {
});
test("tst with severity @allure.label.severity=critical", async ({}) => {
});
test("test with epic @allure.label.epic=login", async ({}) => {
});
test("test with strangeLabel @allure.label.strangeLabel=strangeValue", async ({}) => {
});
```
> **Warning**
> Note that changing title can cause creating new testcases in history.
> To fix this please add `@allure.id={yourTestCaseId}` to the test name if you passing allure
> metadata from test title
More details about Allure Playwright configuration are available at [https://allurereport.org/docs/playwright-configuration/](https://allurereport.org/docs/playwright-configuration/).

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