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-jasmine package #1018

Merged
merged 1 commit into from
Jun 25, 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
4 changes: 3 additions & 1 deletion .pnp.cjs

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

4 changes: 2 additions & 2 deletions packages/allure-jasmine/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = {
overrides: [
{
extends: ["plugin:@typescript-eslint/disable-type-checked"],
files: [".eslintrc.cjs"],
}
files: [".eslintrc.cjs", "vitest.config.ts", "vitest-setup.ts"],
},
],
};
6 changes: 5 additions & 1 deletion packages/allure-jasmine/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@
"dist"
],
"scripts": {
"clean": "rimraf ./dist",
"allure-report": "allure serve ./out/allure-results",
"clean": "rimraf ./dist ./out",
"compile": "run-s 'compile:*'",
"compile:esm-babel": "babel --config-file ./babel.esm.json ./src --out-dir ./dist/esm --extensions '.ts' --source-maps",
"compile:cjs-babel": "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 ./src ./test --ext .ts --fix",
"test": "vitest run"
Expand All @@ -52,6 +54,8 @@
"@types/node": "^20.6.3",
"@typescript-eslint/eslint-plugin": "^7.0.0",
"@typescript-eslint/parser": "^7.0.0",
"allure-commandline": "^2.29.0",
"allure-vitest": "workspace:*",
"babel-plugin-add-module-exports": "^1.0.4",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.0.0",
Expand Down
31 changes: 19 additions & 12 deletions packages/allure-jasmine/test/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { fork } from "node:child_process";
import { randomUUID } from "node:crypto";
import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
import { dirname, join } from "node:path";
import { dirname, extname, join } from "node:path";
import { attachment, step } from "allure-js-commons";
import type { AllureResults } from "allure-js-commons/sdk";
import { MessageReader } from "allure-js-commons/sdk/reporter";

Expand All @@ -17,20 +18,26 @@ export const runJasmineInlineTest = async (files: Record<string, string>): Promi
await mkdir(testDir, { recursive: true });

for (const file of Object.keys(testFiles)) {
const filePath = join(testDir, file);
await step(file, async () => {
const filePath = join(testDir, file);

await mkdir(dirname(filePath), { recursive: true });
await writeFile(filePath, testFiles[file as keyof typeof testFiles] as string, "utf8");
await mkdir(dirname(filePath), { recursive: true });
const content: string = testFiles[file as keyof typeof testFiles];
await writeFile(filePath, content, "utf8");
await attachment(file, content, { encoding: "utf-8", contentType: "text/plain", fileExtension: extname(file) });
});
}

const modulePath = require.resolve("jasmine/bin/jasmine");
const modulePath = await step("resolve jasmine", () => require.resolve("jasmine/bin/jasmine"));
const args: string[] = [];
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 @@ -47,7 +54,7 @@ export const runJasmineInlineTest = async (files: Record<string, string>): Promi
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-jasmine/vitest-setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import "allure-vitest/setup";
3 changes: 2 additions & 1 deletion packages/allure-jasmine/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ 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",
Expand Down
2 changes: 2 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4197,7 +4197,9 @@ __metadata:
"@types/node": "npm:^20.6.3"
"@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:*"
babel-plugin-add-module-exports: "npm:^1.0.4"
eslint: "npm:^8.57.0"
eslint-config-prettier: "npm:^9.0.0"
Expand Down
Loading