Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(playwright) Readme improvements for screenshots, attachments, steps #478

Merged
merged 5 commits into from
Aug 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ categories:
- title: '⬆️ Dependency Updates'
labels:
- 'type:dependencies'
- title: '📝 Docs Update'
labels:
- 'type:docs'

change-template: '* $TITLE (via #$NUMBER) - @$AUTHOR'
exclude-labels:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/labels-verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ jobs:
steps:
- uses: baev/match-label-action@master
with:
allowed: 'type:bug,type:new feature,type:improvement,type:dependencies,type:internal,type:invalid'
allowed: 'type:bug,type:new feature,type:improvement,type:dependencies,type:internal,type:invalid,type:docs'
51 changes: 48 additions & 3 deletions packages/allure-playwright/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,17 +195,62 @@ test("basic test", async ({ page }, testInfo) => {
});
```

### Screenshot usage
```ts
test("basic test", async ({ page }, testInfo) => {
await testInfo.attach("basic-page-screen", {
body: await page.screenshot(),
contentType: "image/png",
});
});

```


### Attachments Usage

```js
import { test, expect } from "@playwright/test";

export const TODO_ITEMS = [
"buy some cheese",
"feed the cat",
"book a doctors appointment",
];

test("basic test", async ({ page }, testInfo) => {
const path = testInfo.outputPath("screenshot.png");
await page.screenshot({ path });
testInfo.attachments.push({ name: "screenshot", path, contentType: "image/png" });
await testInfo.attach("TODO_ITEMS", {
body: JSON.stringify(TODO_ITEMS),
contentType: "application/json",
});
});

```

### Steps usage

```ts
import { test, expect } from "@playwright/test";

export const TODO_ITEMS = [
"buy some cheese",
"feed the cat",
"book a doctors appointment"
];

test("basic test", async ({ page }, testInfo) => {
await test.step("Visit todolist page", async () => {
await page.goto("https://demo.playwright.dev/todomvc");
});

await test.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]]);
});
```