Skip to content

Commit

Permalink
add report for allure-jasmine package
Browse files Browse the repository at this point in the history
  • Loading branch information
baev committed Jun 25, 2024
1 parent 83ac013 commit 999966f
Show file tree
Hide file tree
Showing 14 changed files with 36 additions and 257 deletions.
123 changes: 3 additions & 120 deletions .pnp.cjs

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

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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"],
},
],
};
8 changes: 6 additions & 2 deletions 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 All @@ -65,6 +69,6 @@
"rimraf": "^5.0.1",
"tslib": "^2.6.2",
"typescript": "^5.2.2",
"vitest": "^1.5.3"
"vitest": "^1.6.0"
}
}
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
Loading

0 comments on commit 999966f

Please sign in to comment.