Skip to content

Commit

Permalink
one more attempt
Browse files Browse the repository at this point in the history
  • Loading branch information
baev committed Aug 16, 2024
1 parent d893342 commit 13977df
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions packages/allure-cypress/test/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import { dirname, join, relative, resolve as resolvePath } from "node:path";
import type { TestResult, TestResultContainer } from "allure-js-commons";
import { ContentType, attachment, step } from "allure-js-commons";
import type { AllureResults, EnvironmentInfo } from "allure-js-commons/sdk";
import { parseProperties } from "allure-js-commons/sdk/reporter";
import { getPosixPath, parseProperties } from "allure-js-commons/sdk/reporter";

type CypressModulesPaths = {
allureCommonsModulePath: string;
allureCypressModulePath: string;
allureCypressReporterModulePath: string;
};

Expand All @@ -31,14 +32,12 @@ export const runCypressInlineTest = async (
timestamps: new Map(),
};
const testDir = join(__dirname, "fixtures", randomUUID());
const allureCommonsModulePath = require.resolve("allure-js-commons");
const allureCypressModulePath = require.resolve("allure-cypress");
const allureCypressReporterModulePath = require.resolve("allure-cypress/reporter");

const testFilesToWrite: CypressTestFiles = {
"cypress/support/e2e.js": () => `
"cypress/support/e2e.js": ({ allureCypressModulePath }) => `
require("${allureCypressModulePath}");
`,
"cypress.config.js": () => `
"cypress.config.js": ({ allureCypressReporterModulePath }) => `
const { allureCypress } = require("${allureCypressReporterModulePath}");
module.exports = {
Expand Down Expand Up @@ -66,13 +65,18 @@ export const runCypressInlineTest = async (
};

await step("Prepare files", async () => {
const allureCommonsModulePath = require.resolve("allure-js-commons");
const allureCypressModulePath = require.resolve("allure-cypress");
const allureCypressReporterModulePath = require.resolve("allure-cypress/reporter");

// eslint-disable-next-line guard-for-in
for (const testFile in testFilesToWrite) {
const fileDir = dirname(join(testDir, testFile));
await mkdir(fileDir, { recursive: true });
const content = testFilesToWrite[testFile]({
allureCommonsModulePath: relative(fileDir, allureCommonsModulePath),
allureCypressReporterModulePath,
allureCommonsModulePath: getPosixPath(relative(fileDir, allureCommonsModulePath)),
allureCypressModulePath: getPosixPath(relative(fileDir, allureCypressModulePath)),
allureCypressReporterModulePath: getPosixPath(relative(fileDir, allureCypressReporterModulePath)),
});
await writeFile(join(testDir, testFile), content, "utf8");
await attachment(testFile, content, ContentType.TEXT);
Expand Down

0 comments on commit 13977df

Please sign in to comment.