From 152a0264864d6ac45798db658a3b3a6f29cdc15c Mon Sep 17 00:00:00 2001 From: ortoniKC Date: Fri, 17 Nov 2023 14:05:50 +0530 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=8C=20IMPROVE:=20Treace=20viewer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- readme.md | 3 +++ src/hooks/hooks.ts | 8 ++++---- src/test/features/addToCart.feature | 1 + 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/readme.md b/readme.md index ca61d40..1893dae 100644 --- a/readme.md +++ b/readme.md @@ -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) diff --git a/src/hooks/hooks.ts b/src/hooks/hooks.ts index dac33e6..a0f8f69 100644 --- a/src/hooks/hooks.ts +++ b/src/hooks/hooks.ts @@ -57,16 +57,16 @@ 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" ); @@ -74,7 +74,7 @@ After(async function ({ pickle, result }) { fs.readFileSync(videoPath), 'video/webm' ); - const traceFileLink = `Open` + const traceFileLink = `Open ${path}` await this.attach(`Trace file: ${traceFileLink}`, 'text/html'); } diff --git a/src/test/features/addToCart.feature b/src/test/features/addToCart.feature index 698c0ac..401132c 100644 --- a/src/test/features/addToCart.feature +++ b/src/test/features/addToCart.feature @@ -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 "" And User enter the password as ""