Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
baev committed Jun 6, 2024
1 parent 7ed9470 commit a01fb18
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 0 deletions.
40 changes: 40 additions & 0 deletions packages/allure-vitest/test/spec/categories.test.ts
Original file line number Diff line number Diff line change
@@ -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" })]));
});
39 changes: 39 additions & 0 deletions packages/allure-vitest/test/spec/environmentInfo.test.ts
Original file line number Diff line number Diff line change
@@ -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" });
});

0 comments on commit a01fb18

Please sign in to comment.