Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add report for allure-cucumberjs package #1013

Merged
merged 1 commit into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions .pnp.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/allure-cucumberjs/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = {
overrides: [
{
extends: ["plugin:@typescript-eslint/disable-type-checked"],
files: [".eslintrc.cjs"],
files: [".eslintrc.cjs", "vitest.config.ts", "vitest-setup.ts"],
}
],
};
7 changes: 5 additions & 2 deletions packages/allure-cucumberjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@
"dist"
],
"scripts": {
"allure-report": "allure serve ./out/allure-results",
"clean": "rimraf ./dist ./out",
"compile": "run-s 'compile:*'",
"compile:esm": "babel --config-file ./babel.esm.json ./src --out-dir ./dist/esm --extensions '.ts' --source-maps",
"compile:cjs": "babel --config-file ./babel.cjs.json ./src --out-dir ./dist/cjs --extensions '.ts' --source-maps",
"compile:types": "tsc",
"compile:fixup": "node ./scripts/fixup.mjs",
"generate-report": "allure generate ./out/allure-results -o ./out/allure-report --clean",
"lint": "eslint ./src ./test --ext .ts",
"lint:fix": "eslint --fix ./src ./test --ext .ts",
"test": "vitest run"
Expand Down Expand Up @@ -69,7 +71,8 @@
"@types/sinon": "^17.0.0",
"@typescript-eslint/eslint-plugin": "^7.0.0",
"@typescript-eslint/parser": "^7.0.0",
"allure-vitest": "workspace:^",
"allure-commandline": "^2.29.0",
"allure-vitest": "workspace:*",
"babel-plugin-add-module-exports": "^1.0.4",
"chai": "^4.3.8",
"chai-like": "^1.1.1",
Expand All @@ -86,6 +89,6 @@
"sinon": "^18.0.0",
"ts-node": "^10.9.1",
"typescript": "^5.2.2",
"vitest": "^1.4.0"
"vitest": "^1.6.0"
}
}
75 changes: 54 additions & 21 deletions packages/allure-cucumberjs/test/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { fork } from "node:child_process";
import { randomUUID } from "node:crypto";
import { copyFile, mkdir, rm, writeFile } from "node:fs/promises";
import { dirname, join, resolve as resolvePath } from "node:path";
import { attachment, attachmentPath, step } from "allure-js-commons";
import type { AllureResults } from "allure-js-commons/sdk";
import { MessageReader } from "allure-js-commons/sdk/reporter";

Expand Down Expand Up @@ -57,38 +58,70 @@ export const runCucumberInlineTest = async (
require("allure-cucumberjs");
`;

await mkdir(testDir, { recursive: true });
await mkdir(supportTempPath, { recursive: true });
await writeFile(configFilePath, configContent, "utf8");
await writeFile(reporterFilePath, reporterContent, "utf8");
await writeFile(worldFilePath, worldContent, "utf8");
await step(`create test dir ${testDir}`, async () => {
await mkdir(testDir, { recursive: true });
});
await step(`create support temp dir ${supportTempPath}`, async () => {
await mkdir(supportTempPath, { recursive: true });
});
await step("config.js", async () => {
await writeFile(configFilePath, configContent, "utf8");
await attachment("config.js", configContent, {
contentType: "text/plain",
encoding: "utf-8",
fileExtension: ".js",
});
});
await step("reporter.js", async () => {
await writeFile(reporterFilePath, reporterContent, "utf8");
await attachment("reporter.js", reporterContent, {
contentType: "text/plain",
encoding: "utf-8",
fileExtension: ".js",
});
});
await step("world.js", async () => {
await writeFile(worldFilePath, worldContent, "utf8");
await attachment("world.js", worldContent, {
contentType: "text/plain",
encoding: "utf-8",
fileExtension: ".js",
});
});

await Promise.all(
features.map(async (feature) => {
for (const feature of features) {
await step(`features/${feature}.feature`, async () => {
const featurePath = join(fixturesPath, "features", `${feature}.feature`);

await copyFile(featurePath, join(featuresTempPath, `${feature}.feature`));
}),
);
await Promise.all(
stepsDefs.map(async (stepsDef) => {
await attachmentPath(`features/${feature}.feature`, featurePath, { contentType: "text/plain" });
});
}

for (const stepsDef of stepsDefs) {
await step(`support/${stepsDef}.cjs`, async () => {
const stepsDefPath = join(fixturesPath, "support", `${stepsDef}.cjs`);
const supportFilePath = join(supportTempPath, `${stepsDef}.js`);

await mkdir(dirname(supportFilePath), { recursive: true });

await copyFile(stepsDefPath, supportFilePath);
}),
);
await attachmentPath(`support/${stepsDef}.cjs`, stepsDefPath, { contentType: "text/plain" });
});
}

const modulePath = resolvePath(require.resolve("@cucumber/cucumber"), "../../bin/cucumber-js");
const modulePath = await step("resolve @cucumber/cucumber", () => {
return resolvePath(require.resolve("@cucumber/cucumber"), "../../bin/cucumber-js");
});
const args = ["--config", "./config.js"];
const testProcess = fork(modulePath, args, {
env: {
...process.env,
},
cwd: testDir,
stdio: "pipe",
const testProcess = await step(`${modulePath} ${args.join(" ")}`, () => {
return fork(modulePath, args, {
env: {
...process.env,
},
cwd: testDir,
stdio: "pipe",
});
});

const messageReader = new MessageReader();
Expand All @@ -105,7 +138,7 @@ export const runCucumberInlineTest = async (
return new Promise((resolve) => {
testProcess.on("exit", async () => {
await rm(testDir, { recursive: true });

await messageReader.attachResults();
return resolve(messageReader.results);
});
});
Expand Down
1 change: 1 addition & 0 deletions packages/allure-cucumberjs/vitest-setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import "allure-vitest/setup";
9 changes: 4 additions & 5 deletions packages/allure-cucumberjs/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ export default defineConfig({
dir: "./test/spec",
fileParallelism: false,
testTimeout: 5000,
reporters: [
"default",
],
setupFiles: ["./vitest-setup.ts"],
reporters: ["default", ["allure-vitest/reporter", { resultsDir: "./out/allure-results" }]],
typecheck: {
enabled: true,
tsconfig: "./tsconfig.test.json"
}
tsconfig: "./tsconfig.test.json",
},
},
});
7 changes: 4 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4228,8 +4228,9 @@ __metadata:
"@types/sinon": "npm:^17.0.0"
"@typescript-eslint/eslint-plugin": "npm:^7.0.0"
"@typescript-eslint/parser": "npm:^7.0.0"
allure-commandline: "npm:^2.29.0"
allure-js-commons: "workspace:*"
allure-vitest: "workspace:^"
allure-vitest: "workspace:*"
babel-plugin-add-module-exports: "npm:^1.0.4"
chai: "npm:^4.3.8"
chai-like: "npm:^1.1.1"
Expand All @@ -4246,7 +4247,7 @@ __metadata:
sinon: "npm:^18.0.0"
ts-node: "npm:^10.9.1"
typescript: "npm:^5.2.2"
vitest: "npm:^1.4.0"
vitest: "npm:^1.6.0"
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -4501,7 +4502,7 @@ __metadata:
languageName: unknown
linkType: soft

"allure-vitest@workspace:*, allure-vitest@workspace:^, allure-vitest@workspace:packages/allure-vitest":
"allure-vitest@workspace:*, allure-vitest@workspace:packages/allure-vitest":
version: 0.0.0-use.local
resolution: "allure-vitest@workspace:packages/allure-vitest"
dependencies:
Expand Down
Loading