Skip to content

Commit

Permalink
👌 IMPROVE: Treace viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
ortoniKC committed Nov 17, 2023
1 parent 505a684 commit 152a026
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
3 changes: 3 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ TypeScript is a powerful superset of JavaScript that adds optional static typing
]
```
7. Use tags to run a specific or collection of specs
```
npm run test --TAGS="@test or @add"
```

### Folder structure
0. `src\pages` -> All the page (UI screen)
Expand Down
8 changes: 4 additions & 4 deletions src/hooks/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,24 +57,24 @@ Before({ tags: '@auth' }, async function ({ pickle }) {
After(async function ({ pickle, result }) {
let videoPath: string;
let img: Buffer;
if (result?.status == Status.FAILED) {
const path = `./test-results/trace/${pickle.id}.zip`;
if (result?.status == Status.PASSED) {
img = await fixture.page.screenshot(
{ path: `./test-results/screenshots/${pickle.name}.png`, type: "png" })
videoPath = await fixture.page.video().path();
}
const path = `./test-results/trace/${pickle.id}.zip`;
await context.tracing.stop({ path: path });
await fixture.page.close();
await context.close();
if (result?.status == Status.FAILED) {
if (result?.status == Status.PASSED) {
await this.attach(
img, "image/png"
);
await this.attach(
fs.readFileSync(videoPath),
'video/webm'
);
const traceFileLink = `<a href="https://trace.playwright.dev/?trace=blob&traceFileName=${encodeURIComponent(path)}">Open</a>`
const traceFileLink = `<a href="https://trace.playwright.dev/">Open ${path}</a>`
await this.attach(`Trace file: ${traceFileLink}`, 'text/html');

}
Expand Down
1 change: 1 addition & 0 deletions src/test/features/addToCart.feature
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Feature: Add products to cart
Given User navigates to the application
And User click on the login link

@add
Scenario Outline: Authenticated Users - Add to cart
And User enter the username as "<username>"
And User enter the password as "<password>"
Expand Down

0 comments on commit 152a026

Please sign in to comment.