diff --git a/packages/allure-vitest/src/reporter.ts b/packages/allure-vitest/src/reporter.ts index 5ed361589..0bb41b9b2 100644 --- a/packages/allure-vitest/src/reporter.ts +++ b/packages/allure-vitest/src/reporter.ts @@ -49,6 +49,8 @@ export default class AllureVitestReporter implements Reporter { this.handleTask(task); } } + this.allureReporterRuntime!.writeEnvironmentInfo(); + this.allureReporterRuntime!.writeCategoriesDefinitions(); } async handleTask(task: Task) { diff --git a/packages/allure-vitest/test/spec/categories.test.ts b/packages/allure-vitest/test/spec/categories.test.ts new file mode 100644 index 000000000..7d6f6054e --- /dev/null +++ b/packages/allure-vitest/test/spec/categories.test.ts @@ -0,0 +1,40 @@ +import { join } from "node:path"; +import { expect, it } from "vitest"; +import { runVitestInlineTest } from "../utils.js"; + +it("should support categories", async () => { + const { categories } = await runVitestInlineTest( + ` + import { test } from "vitest"; + + test("sample test", async () => { + }); + `, + (testDir) => ` + import { defineConfig } from "vitest/config"; + + export default defineConfig({ + test: { + setupFiles: ["allure-vitest/setup"], + reporters: [ + "default", + [ + "allure-vitest/reporter", + { + testMode: true, + resultsDir: "${join(testDir, "allure-results")}", + categories: [{ + name: "first" + },{ + name: "second" + }] + } + ], + ], + }, + }); + `, + ); + + expect(categories).toEqual(expect.arrayContaining([({ name: "first" }, { name: "second" })])); +}); diff --git a/packages/allure-vitest/test/spec/environmentInfo.test.ts b/packages/allure-vitest/test/spec/environmentInfo.test.ts new file mode 100644 index 000000000..133b243d7 --- /dev/null +++ b/packages/allure-vitest/test/spec/environmentInfo.test.ts @@ -0,0 +1,39 @@ +import { join } from "node:path"; +import { expect, it } from "vitest"; +import { runVitestInlineTest } from "../utils.js"; + +it("should support environmentInfo", async () => { + const { envInfo } = await runVitestInlineTest( + ` + import { test } from "vitest"; + + test("sample test", async () => { + }); + `, + (testDir) => ` + import { defineConfig } from "vitest/config"; + + export default defineConfig({ + test: { + setupFiles: ["allure-vitest/setup"], + reporters: [ + "default", + [ + "allure-vitest/reporter", + { + testMode: true, + resultsDir: "${join(testDir, "allure-results")}", + environmentInfo: { + "app version": "123.0.1", + "some other key": "some other value" + } + } + ], + ], + }, + }); + `, + ); + + expect(envInfo).toEqual({ "app version": "123.0.1", "some other key": "some other value" }); +});