From 9f1bd9e43b3bb15ae374469d17d692e18bc48453 Mon Sep 17 00:00:00 2001 From: Roi Carrera Date: Mon, 11 Nov 2024 14:37:32 +0100 Subject: [PATCH] small fixes --- e2e-cypress/files/pdf-generator.ts | 3 ++- e2e-cypress/files/support/e2e.ts | 6 +++--- e2e-cypress/files/support/test-evidence.ts | 3 ++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/e2e-cypress/files/pdf-generator.ts b/e2e-cypress/files/pdf-generator.ts index 05c8b317..4922f58b 100644 --- a/e2e-cypress/files/pdf-generator.ts +++ b/e2e-cypress/files/pdf-generator.ts @@ -1,6 +1,7 @@ import * as puppeteer from 'puppeteer'; import * as path from 'path'; import * as fs from 'fs'; +import baseConfig from './cypress.config'; async function expandReportTestCases(htmlPage: puppeteer.Page) { await htmlPage.evaluate(() => { @@ -11,7 +12,7 @@ async function expandReportTestCases(htmlPage: puppeteer.Page) { }); } -const mochawesomeDir = path.resolve(__dirname, 'build/test-results/mochawesome/'); +const mochawesomeDir = path.resolve(__dirname, baseConfig.reporterOptions.mochawesomeReporterOptions.reportDir); const isLocal = process.env.NODE_ENV === 'local'; diff --git a/e2e-cypress/files/support/e2e.ts b/e2e-cypress/files/support/e2e.ts index 714ccedf..09aaab36 100644 --- a/e2e-cypress/files/support/e2e.ts +++ b/e2e-cypress/files/support/e2e.ts @@ -17,12 +17,12 @@ afterEach(function() { consoleLogs.splice(0); }) -Cypress.Commands.add('addContextPath', (title: string, screenshot: string) => { +Cypress.Commands.add('addContextPath', (title: string, contextPath: string) => { cy.on('test:after:run', (attributes) => { - // The context needs the screenshot path relative to the build/test-results/mochawesome folder + // The context needs the path relative to the build/test-results/mochawesome folder addContext({ test: attributes }, { title: title, - value: screenshot + value: contextPath }); }); }) diff --git a/e2e-cypress/files/support/test-evidence.ts b/e2e-cypress/files/support/test-evidence.ts index eca2d219..ceb38559 100644 --- a/e2e-cypress/files/support/test-evidence.ts +++ b/e2e-cypress/files/support/test-evidence.ts @@ -1,6 +1,7 @@ import * as path from 'path'; import { isScreenshotEvidenceResult, ScreenshotEvidenceData } from "../plugins/screenshot.types"; import { consoleLogs } from "./e2e"; +import baseConfig from './cypress.config'; const logEvidence = (name: string, step: number, description: string, evidenceLogs: string[]) => { cy.url().then(url => { @@ -67,7 +68,7 @@ export const takeScreenshotEvidence = (testName: string, testStep: number, testS ]); // Create a relative path from the screenshots folder to the mochawesome test-results folder - const relativePath = path.relative('build/test-results/mochawesome', result.path.replace(/^.*(build.*)$/, '$1')); + const relativePath = path.relative(baseConfig.reporterOptions.mochawesomeReporterOptions.reportDir, result.path.replace(/^.*(build.*)$/, '$1')); cy.addContextPath(`${testName} ${testStep} ${testSubStep}`, relativePath); }); });