Skip to content

Commit

Permalink
small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
roicarrera committed Nov 11, 2024
1 parent cf20766 commit 9f1bd9e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion e2e-cypress/files/pdf-generator.ts
Original file line number Diff line number Diff line change
@@ -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(() => {
Expand All @@ -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';

Expand Down
6 changes: 3 additions & 3 deletions e2e-cypress/files/support/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
});
})
3 changes: 2 additions & 1 deletion e2e-cypress/files/support/test-evidence.ts
Original file line number Diff line number Diff line change
@@ -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 => {
Expand Down Expand Up @@ -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);
});
});
Expand Down

0 comments on commit 9f1bd9e

Please sign in to comment.