From 0882050105a20b2ee69d82da71720eddf6a5c46c Mon Sep 17 00:00:00 2001 From: Konstantin Epishev Date: Thu, 18 Jan 2024 15:46:12 +0100 Subject: [PATCH] fix vitest files resolving (via #845) --- packages/allure-vitest/README.md | 6 +- packages/allure-vitest/package.json | 20 ++- packages/allure-vitest/src/index.ts | 144 +++++++----------- packages/allure-vitest/src/setup.ts | 8 +- .../test/spec/setup/attachments.test.ts | 4 +- .../test/spec/setup/description.test.ts | 8 +- .../test/spec/setup/displayName.test.ts | 4 +- .../test/spec/setup/historyId.test.ts | 4 +- .../test/spec/setup/labels.test.ts | 48 +++--- .../test/spec/setup/links.test.ts | 43 +----- .../test/spec/setup/parameters.test.ts | 4 +- .../test/spec/setup/steps.test.ts | 12 +- .../test/spec/setup/testCaseId.test.ts | 4 +- packages/allure-vitest/test/utils.ts | 44 +++--- packages/allure-vitest/tsconfig.json | 11 +- packages/allure-vitest/vitest.config.ts | 2 +- 16 files changed, 156 insertions(+), 210 deletions(-) diff --git a/packages/allure-vitest/README.md b/packages/allure-vitest/README.md index 60801b8db..2d8e43580 100644 --- a/packages/allure-vitest/README.md +++ b/packages/allure-vitest/README.md @@ -29,13 +29,13 @@ yarn add -D vitest allure-vitest Add instance of the reporter to the [`reporters` section](https://vitest.dev/config/#reporters) of your Vitest config: ```js -import AllureReporter from "allure-vitest"; +import AllureReporter from "allure-vitest/reporter"; import { defineConfig } from "vitest/config"; export default defineConfig({ test: { // add setup file to be able to use Allure API via `this.allure` in your tests - setupFiles: ["allure-vitest/setup], + setupFiles: ["allure-vitest/setup"], reporters: [ // do not forget to keep the "default" if you want to see something in the console "default", @@ -75,7 +75,7 @@ to Allure Runtime API: import { test } from "vitest"; test("sample test", async () => { - await this.allure.label("foo", "bar"); + await allure.label("foo", "bar"); }); ``` diff --git a/packages/allure-vitest/package.json b/packages/allure-vitest/package.json index 084c2868f..4ef881cfe 100644 --- a/packages/allure-vitest/package.json +++ b/packages/allure-vitest/package.json @@ -21,12 +21,22 @@ }, "type": "module", "exports": { - ".": "./dist/src/index.js", - "./setup": "./dist/src/setup.js", - "./reporter": "./dist/src/reporter.js" + ".": { + "import": "./dist/index.js", + "types": "./dist/index.d.ts" + }, + "./reporter": { + "import": "./dist/reporter.js", + "types": "./dist/reporter.d.ts" + }, + "./setup": { + "require": "./dist/setup.js", + "import": "./dist/setup.js", + "types": "./dist/setup.d.ts" + } }, - "main": "./dist/src/index.js", - "types": "./dist/src/index.d.ts", + "module": "./dist/index.js", + "types": "./dist/index.d.ts", "files": [ "dist" ], diff --git a/packages/allure-vitest/src/index.ts b/packages/allure-vitest/src/index.ts index 9bc7b1708..85179a293 100644 --- a/packages/allure-vitest/src/index.ts +++ b/packages/allure-vitest/src/index.ts @@ -1,3 +1,4 @@ +/* eslint @typescript-eslint/require-await: 0 */ import * as vitest from "vitest"; import { LabelName, LinkType, MetadataMessage, ParameterOptions, Stage, Status, StepMetadata } from "allure-js-commons"; @@ -27,82 +28,87 @@ const injectAllureMeta = (context: vitest.TaskContext) => { }; }; -export const label = (context: vitest.TaskContext, name: string, value: string) => { +export const label = async (context: vitest.TaskContext, name: string, value: string) => { injectAllureMeta(context); (context.task.meta as AllureTestMeta).currentTest.labels.push({ name, value }); }; -export const link = (context: vitest.TaskContext, type: LinkType, url: string, name?: string) => { +export const link = async (context: vitest.TaskContext, type: LinkType, url: string, name?: string) => { injectAllureMeta(context); (context.task.meta as AllureTestMeta).currentTest.links.push({ type, url, name }); }; -export const epic = (context: vitest.TaskContext, value: string) => { +export const epic = async (context: vitest.TaskContext, value: string) => { injectAllureMeta(context); label(context, LabelName.EPIC, value); }; -export const feature = (context: vitest.TaskContext, value: string) => { +export const feature = async (context: vitest.TaskContext, value: string) => { injectAllureMeta(context); label(context, LabelName.FEATURE, value); }; -export const story = (context: vitest.TaskContext, value: string) => { +export const story = async (context: vitest.TaskContext, value: string) => { injectAllureMeta(context); label(context, LabelName.STORY, value); }; -export const suite = (context: vitest.TaskContext, value: string) => { +export const suite = async (context: vitest.TaskContext, value: string) => { injectAllureMeta(context); label(context, LabelName.SUITE, value); }; -export const parentSuite = (context: vitest.TaskContext, value: string) => { +export const parentSuite = async (context: vitest.TaskContext, value: string) => { injectAllureMeta(context); label(context, LabelName.PARENT_SUITE, value); }; -export const subSuite = (context: vitest.TaskContext, value: string) => { +export const subSuite = async (context: vitest.TaskContext, value: string) => { injectAllureMeta(context); label(context, LabelName.SUB_SUITE, value); }; -export const owner = (context: vitest.TaskContext, value: string) => { +export const owner = async (context: vitest.TaskContext, value: string) => { injectAllureMeta(context); label(context, LabelName.OWNER, value); }; -export const severity = (context: vitest.TaskContext, value: string) => { +export const severity = async (context: vitest.TaskContext, value: string) => { injectAllureMeta(context); label(context, LabelName.SEVERITY, value); }; -export const layer = (context: vitest.TaskContext, value: string) => { +export const layer = async (context: vitest.TaskContext, value: string) => { injectAllureMeta(context); label(context, LabelName.LAYER, value); }; -export const tag = (context: vitest.TaskContext, value: string) => { +export const tag = async (context: vitest.TaskContext, value: string) => { injectAllureMeta(context); label(context, LabelName.TAG, value); }; -export const allureId = (context: vitest.TaskContext, value: string) => { +export const allureId = async (context: vitest.TaskContext, value: string) => { injectAllureMeta(context); label(context, LabelName.ALLURE_ID, value); }; -export const issue = (context: vitest.TaskContext, name: string, url: string) => { +export const issue = async (context: vitest.TaskContext, name: string, url: string) => { injectAllureMeta(context); link(context, LinkType.ISSUE, url, name); }; -export const tms = (context: vitest.TaskContext, name: string, url: string) => { +export const tms = async (context: vitest.TaskContext, name: string, url: string) => { injectAllureMeta(context); link(context, LinkType.TMS, url, name); }; -export const parameter = (context: vitest.TaskContext, name: string, value: string, options?: ParameterOptions) => { +export const parameter = async ( + context: vitest.TaskContext, + name: string, + value: string, + options?: ParameterOptions, +) => { injectAllureMeta(context); (context.task.meta as AllureTestMeta).currentTest.parameter.push({ name, @@ -111,32 +117,32 @@ export const parameter = (context: vitest.TaskContext, name: string, value: stri }); }; -export const description = (context: vitest.TaskContext, markdown: string) => { +export const description = async (context: vitest.TaskContext, markdown: string) => { injectAllureMeta(context); (context.task.meta as AllureTestMeta).currentTest.description = markdown; }; -export const descriptionHtml = (context: vitest.TaskContext, html: string) => { +export const descriptionHtml = async (context: vitest.TaskContext, html: string) => { injectAllureMeta(context); (context.task.meta as AllureTestMeta).currentTest.descriptionHtml = html; }; -export const displayName = (context: vitest.TaskContext, name: string) => { +export const displayName = async (context: vitest.TaskContext, name: string) => { injectAllureMeta(context); (context.task.meta as AllureTestMeta).currentTest.displayName = name; }; -export const historyId = (context: vitest.TaskContext, value: string) => { +export const historyId = async (context: vitest.TaskContext, value: string) => { injectAllureMeta(context); (context.task.meta as AllureTestMeta).currentTest.historyId = value; }; -export const testCaseId = (context: vitest.TaskContext, value: string) => { +export const testCaseId = async (context: vitest.TaskContext, value: string) => { injectAllureMeta(context); (context.task.meta as AllureTestMeta).currentTest.testCaseId = value; }; -export const attachment = (context: vitest.TaskContext, name: string, content: Buffer | string, type: string) => { +export const attachment = async (context: vitest.TaskContext, name: string, content: Buffer | string, type: string) => { injectAllureMeta(context); const { currentTest, currentStep } = context.task.meta as AllureTestMeta; @@ -185,74 +191,30 @@ export const step = async (context: vitest.TaskContext, name: string, body: () = export const bindAllureApi = (task: vitest.Task) => { return { - label: (name: string, value: string) => { - label({ task } as vitest.TaskContext, name, value); - }, - link: (type: LinkType, url: string, name?: string) => { - link({ task } as vitest.TaskContext, type, url, name); - }, - parameter: (name: string, value: string, options?: ParameterOptions) => { - parameter({ task } as vitest.TaskContext, name, value, options); - }, - description: (markdown: string) => { - description({ task } as vitest.TaskContext, markdown); - }, - descriptionHtml: (html: string) => { - descriptionHtml({ task } as vitest.TaskContext, html); - }, - testCaseId: (id: string) => { - testCaseId({ task } as vitest.TaskContext, id); - }, - historyId: (id: string) => { - historyId({ task } as vitest.TaskContext, id); - }, - allureId: (id: string) => { - allureId({ task } as vitest.TaskContext, id); - }, - displayName: (name: string) => { - displayName({ task } as vitest.TaskContext, name); - }, - attachment: (name: string, content: Buffer | string, type: string) => { - attachment({ task } as vitest.TaskContext, name, content, type); - }, - issue: (name: string, url: string) => { - issue({ task } as vitest.TaskContext, name, url); - }, - tms: (name: string, url: string) => { - tms({ task } as vitest.TaskContext, name, url); - }, - epic: (name: string) => { - epic({ task } as vitest.TaskContext, name); - }, - feature: (name: string) => { - feature({ task } as vitest.TaskContext, name); - }, - story: (name: string) => { - story({ task } as vitest.TaskContext, name); - }, - suite: (name: string) => { - suite({ task } as vitest.TaskContext, name); - }, - parentSuite: (name: string) => { - parentSuite({ task } as vitest.TaskContext, name); - }, - subSuite: (name: string) => { - subSuite({ task } as vitest.TaskContext, name); - }, - owner: (name: string) => { - owner({ task } as vitest.TaskContext, name); - }, - severity: (name: string) => { - severity({ task } as vitest.TaskContext, name); - }, - layer: (name: string) => { - layer({ task } as vitest.TaskContext, name); - }, - tag: (name: string) => { - tag({ task } as vitest.TaskContext, name); - }, - step: (name: string, body: () => Promise) => { - step({ task } as vitest.TaskContext, name, body); - }, + label: (name: string, value: string) => label({ task } as vitest.TaskContext, name, value), + link: (type: LinkType, url: string, name?: string) => link({ task } as vitest.TaskContext, type, url, name), + parameter: (name: string, value: string, options?: ParameterOptions) => + parameter({ task } as vitest.TaskContext, name, value, options), + description: (markdown: string) => description({ task } as vitest.TaskContext, markdown), + descriptionHtml: (html: string) => descriptionHtml({ task } as vitest.TaskContext, html), + testCaseId: (id: string) => testCaseId({ task } as vitest.TaskContext, id), + historyId: (id: string) => historyId({ task } as vitest.TaskContext, id), + allureId: (id: string) => allureId({ task } as vitest.TaskContext, id), + displayName: (name: string) => displayName({ task } as vitest.TaskContext, name), + attachment: (name: string, content: Buffer | string, type: string) => + attachment({ task } as vitest.TaskContext, name, content, type), + issue: (name: string, url: string) => issue({ task } as vitest.TaskContext, name, url), + tms: (name: string, url: string) => tms({ task } as vitest.TaskContext, name, url), + epic: (name: string) => epic({ task } as vitest.TaskContext, name), + feature: (name: string) => feature({ task } as vitest.TaskContext, name), + story: (name: string) => story({ task } as vitest.TaskContext, name), + suite: (name: string) => suite({ task } as vitest.TaskContext, name), + parentSuite: (name: string) => parentSuite({ task } as vitest.TaskContext, name), + subSuite: (name: string) => subSuite({ task } as vitest.TaskContext, name), + owner: (name: string) => owner({ task } as vitest.TaskContext, name), + severity: (name: string) => severity({ task } as vitest.TaskContext, name), + layer: (name: string) => layer({ task } as vitest.TaskContext, name), + tag: (name: string) => tag({ task } as vitest.TaskContext, name), + step: (name: string, body: () => Promise) => step({ task } as vitest.TaskContext, name, body), }; }; diff --git a/packages/allure-vitest/src/setup.ts b/packages/allure-vitest/src/setup.ts index 9e0e451a2..3222b57bd 100644 --- a/packages/allure-vitest/src/setup.ts +++ b/packages/allure-vitest/src/setup.ts @@ -13,13 +13,9 @@ beforeEach((ctx) => { attachments: [], }; - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore - this.allure = bindAllureApi(ctx.task); + global.allure = bindAllureApi(ctx.task); }); afterEach(() => { - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore - this.allure = undefined; + global.allure = undefined; }); diff --git a/packages/allure-vitest/test/spec/setup/attachments.test.ts b/packages/allure-vitest/test/spec/setup/attachments.test.ts index 1d2212e9e..3ca82da00 100644 --- a/packages/allure-vitest/test/spec/setup/attachments.test.ts +++ b/packages/allure-vitest/test/spec/setup/attachments.test.ts @@ -5,8 +5,8 @@ it("adds attachments", async () => { const { tests, attachments } = await runVitestInlineTest(` import { test } from "vitest"; - test("text attachment", () => { - this.allure.attachment("foo.txt", Buffer.from("bar"), "text/plain"); + test("text attachment", async () => { + await allure.attachment("foo.txt", Buffer.from("bar"), "text/plain"); }); `); diff --git a/packages/allure-vitest/test/spec/setup/description.test.ts b/packages/allure-vitest/test/spec/setup/description.test.ts index df1fb8310..6610dac0b 100644 --- a/packages/allure-vitest/test/spec/setup/description.test.ts +++ b/packages/allure-vitest/test/spec/setup/description.test.ts @@ -5,8 +5,8 @@ it("sets description", async () => { const { tests } = await runVitestInlineTest(` import { test } from "vitest"; - test("description", () => { - this.allure.description("foo"); + test("description", async () => { + await allure.description("foo"); }); `); @@ -18,8 +18,8 @@ it("sets html description", async () => { const { tests } = await runVitestInlineTest(` import { test } from "vitest"; - test("description html", () => { - this.allure.descriptionHtml("foo"); + test("description html", async () => { + await allure.descriptionHtml("foo"); }); `); diff --git a/packages/allure-vitest/test/spec/setup/displayName.test.ts b/packages/allure-vitest/test/spec/setup/displayName.test.ts index 3867a8a9d..eeb95d80a 100644 --- a/packages/allure-vitest/test/spec/setup/displayName.test.ts +++ b/packages/allure-vitest/test/spec/setup/displayName.test.ts @@ -5,8 +5,8 @@ it("sets test display name", async () => { const { tests } = await runVitestInlineTest(` import { test } from "vitest"; - test("display name", () => { - this.allure.displayName("foo"); + test("display name", async () => { + await allure.displayName("foo"); }); `); diff --git a/packages/allure-vitest/test/spec/setup/historyId.test.ts b/packages/allure-vitest/test/spec/setup/historyId.test.ts index c0828f1a5..8e0f90bab 100644 --- a/packages/allure-vitest/test/spec/setup/historyId.test.ts +++ b/packages/allure-vitest/test/spec/setup/historyId.test.ts @@ -5,8 +5,8 @@ it("sets test history id", async () => { const { tests } = await runVitestInlineTest(` import { test } from "vitest"; - test("history id", () => { - this.allure.historyId("foo"); + test("history id", async () => { + await allure.historyId("foo"); }); `); diff --git a/packages/allure-vitest/test/spec/setup/labels.test.ts b/packages/allure-vitest/test/spec/setup/labels.test.ts index ec89b103e..dbcf1520a 100644 --- a/packages/allure-vitest/test/spec/setup/labels.test.ts +++ b/packages/allure-vitest/test/spec/setup/labels.test.ts @@ -7,8 +7,8 @@ describe("labels", () => { const { tests } = await runVitestInlineTest(` import { test } from "vitest"; - test("label", () => { - this.allure.label("foo", "bar"); + test("label", async () => { + await allure.label("foo", "bar"); }); `); @@ -20,8 +20,8 @@ describe("labels", () => { const { tests } = await runVitestInlineTest(` import { test } from "vitest"; - test("epic", () => { - this.allure.epic("foo"); + test("epic", async () => { + await allure.epic("foo"); }); `); @@ -33,8 +33,8 @@ describe("labels", () => { const { tests } = await runVitestInlineTest(` import { test } from "vitest"; - test("feature", () => { - this.allure.feature("foo"); + test("feature", async () => { + await allure.feature("foo"); }); `); @@ -46,8 +46,8 @@ describe("labels", () => { const { tests } = await runVitestInlineTest(` import { test } from "vitest"; - test("story", () => { - this.allure.story("foo"); + test("story", async () => { + await allure.story("foo"); }); `); @@ -59,8 +59,8 @@ describe("labels", () => { const { tests } = await runVitestInlineTest(` import { test } from "vitest"; - test("suite", () => { - this.allure.suite("foo"); + test("suite", async () => { + await allure.suite("foo"); }); `); @@ -72,8 +72,8 @@ describe("labels", () => { const { tests } = await runVitestInlineTest(` import { test } from "vitest"; - test("parentSuite", () => { - this.allure.parentSuite("foo"); + test("parentSuite", async () => { + await allure.parentSuite("foo"); }); `); @@ -85,8 +85,8 @@ describe("labels", () => { const { tests } = await runVitestInlineTest(` import { test } from "vitest"; - test("subSuite", () => { - this.allure.subSuite("foo"); + test("subSuite", async () => { + await allure.subSuite("foo"); }); `); @@ -98,8 +98,8 @@ describe("labels", () => { const { tests } = await runVitestInlineTest(` import { test } from "vitest"; - test("owner", () => { - this.allure.owner("foo"); + test("owner", async () => { + await allure.owner("foo"); }); `); @@ -111,8 +111,8 @@ describe("labels", () => { const { tests } = await runVitestInlineTest(` import { test } from "vitest"; - test("severity", () => { - this.allure.severity("foo"); + test("severity", async () => { + await allure.severity("foo"); }); `); @@ -124,8 +124,8 @@ describe("labels", () => { const { tests } = await runVitestInlineTest(` import { test } from "vitest"; - test("layer", () => { - this.allure.layer("foo"); + test("layer", async () => { + await allure.layer("foo"); }); `); @@ -137,8 +137,8 @@ describe("labels", () => { const { tests } = await runVitestInlineTest(` import { test } from "vitest"; - test("allureId", () => { - this.allure.allureId("foo"); + test("allureId", async () => { + await allure.allureId("foo"); }); `); @@ -150,8 +150,8 @@ describe("labels", () => { const { tests } = await runVitestInlineTest(` import { test } from "vitest"; - test("tag", () => { - this.allure.tag("foo"); + test("tag", async () => { + await allure.tag("foo"); }); `); diff --git a/packages/allure-vitest/test/spec/setup/links.test.ts b/packages/allure-vitest/test/spec/setup/links.test.ts index 12cd031b0..78e425326 100644 --- a/packages/allure-vitest/test/spec/setup/links.test.ts +++ b/packages/allure-vitest/test/spec/setup/links.test.ts @@ -1,36 +1,7 @@ -import { join } from "node:path"; import { describe, expect, it } from "vitest"; import { LinkType } from "allure-js-commons"; import { runVitestInlineTest } from "../../utils.js"; -const config = (testDir: string) => ` - import AllureReporter from "allure-vitest/reporter"; - import { defineConfig } from "vitest/config"; - - export default defineConfig({ - test: { - setupFiles: ["allure-vitest/setup"], - reporters: [ - "default", - new AllureReporter({ - testMode: true, - links: [ - { - type: "issue", - urlTemplate: "https://example.org/issue/%s", - }, - { - type: "tms", - urlTemplate: "https://example.org/tms/%s", - }, - ], - resultsDir: "${join(testDir, "allure-results")}", - }), - ], - }, - }); -`; - describe("links", () => { it("link", async () => { const { tests } = await runVitestInlineTest( @@ -38,7 +9,7 @@ describe("links", () => { import { test } from "vitest"; test("link", async (t) => { - await this.allure.link("foo", "https://example.org", "bar"); + await allure.link("foo", "https://example.org", "bar"); }); `, ); @@ -57,11 +28,10 @@ describe("links", () => { import { test } from "vitest"; test("issue", async () => { - await this.allure.issue("foo", "https://example.org/issue/1"); - await this.allure.issue("bar", "2"); + await allure.issue("foo", "https://example.org/issue/1"); + await allure.issue("bar", "2"); }); `, - config, ); expect(tests).toHaveLength(1); @@ -82,12 +52,11 @@ describe("links", () => { ` import { test } from "vitest"; - test("tms", async (t) => { - await this.allure.tms("foo", "https://example.org/tms/1"); - await this.allure.tms("bar", "2"); + test("tms", async () => { + await allure.tms("foo", "https://example.org/tms/1"); + await allure.tms("bar", "2"); }); `, - config, ); expect(tests).toHaveLength(1); diff --git a/packages/allure-vitest/test/spec/setup/parameters.test.ts b/packages/allure-vitest/test/spec/setup/parameters.test.ts index 6cfbcd309..a45ab4f50 100644 --- a/packages/allure-vitest/test/spec/setup/parameters.test.ts +++ b/packages/allure-vitest/test/spec/setup/parameters.test.ts @@ -5,8 +5,8 @@ it("sets parameters", async () => { const { tests } = await runVitestInlineTest(` import { test } from "vitest"; - test("parameter", () => { - this.allure.parameter("foo", "bar", { mode: "hidden", excluded: true }); + test("parameter", async () => { + await allure.parameter("foo", "bar", { mode: "hidden", excluded: true }); }); `); diff --git a/packages/allure-vitest/test/spec/setup/steps.test.ts b/packages/allure-vitest/test/spec/setup/steps.test.ts index d8d63af69..d314eb5fe 100644 --- a/packages/allure-vitest/test/spec/setup/steps.test.ts +++ b/packages/allure-vitest/test/spec/setup/steps.test.ts @@ -7,7 +7,7 @@ it("handles single lambda step", async () => { import { test } from "vitest"; test("steps", async () => { - await this.allure.step("step", () => {}); + await allure.step("step", () => {}); }); `); @@ -25,8 +25,8 @@ it("handles single lambda step with attachment", async () => { import { test } from "vitest"; test("steps", async () => { - await this.allure.step("step", () => { - this.allure.attachment("foo.txt", Buffer.from("bar"), "text/plain"); + await allure.step("step", () => { + allure.attachment("foo.txt", Buffer.from("bar"), "text/plain"); }); }); `); @@ -47,9 +47,9 @@ it("handles nested lambda steps", async () => { import { test } from "vitest"; test("steps", async () => { - await this.allure.step("step 1", async () => { - await this.allure.step("step 2", async () => { - await this.allure.step("step 3", () => { + await allure.step("step 1", async () => { + await allure.step("step 2", async () => { + await allure.step("step 3", () => { }); }); }); diff --git a/packages/allure-vitest/test/spec/setup/testCaseId.test.ts b/packages/allure-vitest/test/spec/setup/testCaseId.test.ts index a38768c08..d7857afb6 100644 --- a/packages/allure-vitest/test/spec/setup/testCaseId.test.ts +++ b/packages/allure-vitest/test/spec/setup/testCaseId.test.ts @@ -5,8 +5,8 @@ it("sets test case id", async () => { const { tests } = await runVitestInlineTest(` import { test } from "vitest"; - test("test case id", () => { - this.allure.testCaseId("foo"); + test("test case id", async () => { + await allure.testCaseId("foo"); }); `); diff --git a/packages/allure-vitest/test/utils.ts b/packages/allure-vitest/test/utils.ts index b7639c124..84b2fcb89 100644 --- a/packages/allure-vitest/test/utils.ts +++ b/packages/allure-vitest/test/utils.ts @@ -7,7 +7,7 @@ import type { AllureResults, TestResult, TestResultContainer } from "allure-js-c const fileDirname = dirname(fileURLToPath(import.meta.url)); -export const runVitestInlineTest = async (test: string, config?: (cwd: string) => string): Promise => { +export const runVitestInlineTest = async (test: string): Promise => { const res: AllureResults = { tests: [], groups: [], @@ -16,24 +16,32 @@ export const runVitestInlineTest = async (test: string, config?: (cwd: string) = const testDir = join(fileDirname, "fixtures", randomUUID()); const configFilePath = join(testDir, "vitest.config.ts"); const testFilePath = join(testDir, "sample.test.ts"); - const configContent = config - ? config(testDir) - : ` - import AllureReporter from "allure-vitest/reporter"; - import { defineConfig } from "vitest/config"; + const configContent = ` + import AllureReporter from "allure-vitest/reporter"; + import { defineConfig } from "vitest/config"; - export default defineConfig({ - test: { - setupFiles: ["allure-vitest/setup"], - reporters: [ - "default", - new AllureReporter({ - testMode: true, - resultsDir: "${join(testDir, "allure-results")}", - }), - ], - }, - }); + export default defineConfig({ + test: { + setupFiles: ["allure-vitest/setup"], + reporters: [ + "default", + new AllureReporter({ + testMode: true, + links: [ + { + type: "issue", + urlTemplate: "https://example.org/issue/%s", + }, + { + type: "tms", + urlTemplate: "https://example.org/tms/%s", + }, + ], + resultsDir: "${join(testDir, "allure-results")}", + }), + ], + }, + }); `; await mkdir(testDir, { recursive: true }); diff --git a/packages/allure-vitest/tsconfig.json b/packages/allure-vitest/tsconfig.json index 2ef5fab48..3e464d690 100644 --- a/packages/allure-vitest/tsconfig.json +++ b/packages/allure-vitest/tsconfig.json @@ -4,11 +4,12 @@ "lib": ["es2022"], "types": [], "skipLibCheck": true, - "module": "nodenext", - "moduleResolution": "nodenext", + "module": "NodeNext", "declaration": true, - "rootDir": ".", - "outDir": "dist" + "rootDir": "./src", + "outDir": "./dist" }, - "include": ["src"] + "include": [ + "./src/**/*", + ], } diff --git a/packages/allure-vitest/vitest.config.ts b/packages/allure-vitest/vitest.config.ts index 7d71b70db..ed182e86f 100644 --- a/packages/allure-vitest/vitest.config.ts +++ b/packages/allure-vitest/vitest.config.ts @@ -1,5 +1,5 @@ -import AllureReporter from "allure-vitest/reporter"; import { defineConfig } from "vitest/config"; +import AllureReporter from "allure-vitest/reporter"; export default defineConfig({ test: {