From de394d7cd09849f769e0ed2666d35ad0071fbc36 Mon Sep 17 00:00:00 2001 From: metonym Date: Sun, 7 Apr 2024 12:28:41 -0700 Subject: [PATCH] test: use vitest globals --- package.json | 2 +- tests/Writer.test.ts | 1 - tests/WriterMarkdown.test.ts | 1 - tests/create-exports.test.ts | 1 - tests/element-tag-map.test.ts | 1 - tests/fixtures.test.ts | 1 - tests/parse-exports.test.ts | 1 - tests/writer-ts-definitions.test.ts | 5 ++--- tsconfig.build.json | 8 ++++++++ tsconfig.json | 9 +++++---- vite.config.ts | 8 ++++++++ 11 files changed, 24 insertions(+), 14 deletions(-) create mode 100644 tsconfig.build.json create mode 100644 vite.config.ts diff --git a/package.json b/package.json index 343effee..bfabf613 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "test": "vitest -r tests", "test:integration": "node tests/test-integration", "format": "prettier --write \"{src,tests,playground}/**/*.{js,ts,svelte,md}\" --ignore-path \".gitignore\"", - "prepack": "tsc" + "prepack": "tsc -p tsconfig.build.json" }, "dependencies": { "@rollup/plugin-node-resolve": "^13.2.1", diff --git a/tests/Writer.test.ts b/tests/Writer.test.ts index 2b5cbee8..e1396c5a 100644 --- a/tests/Writer.test.ts +++ b/tests/Writer.test.ts @@ -1,4 +1,3 @@ -import { beforeEach, describe, expect, test, vi } from "vitest"; import Writer from "../src/writer/Writer"; describe("Writer", () => { diff --git a/tests/WriterMarkdown.test.ts b/tests/WriterMarkdown.test.ts index d33d74d0..fa24d37a 100644 --- a/tests/WriterMarkdown.test.ts +++ b/tests/WriterMarkdown.test.ts @@ -1,4 +1,3 @@ -import { test, expect } from "vitest"; import WriterMarkdown from "../src/writer/WriterMarkdown"; import type { AppendType } from "../src/writer/WriterMarkdown"; diff --git a/tests/create-exports.test.ts b/tests/create-exports.test.ts index 394271e5..3f339800 100644 --- a/tests/create-exports.test.ts +++ b/tests/create-exports.test.ts @@ -1,4 +1,3 @@ -import { describe, expect, test } from "vitest"; import { convertSvelteExt, createExports, removeSvelteExt } from "../src/create-exports"; describe("createExports", () => { diff --git a/tests/element-tag-map.test.ts b/tests/element-tag-map.test.ts index d323d14b..72c71db9 100644 --- a/tests/element-tag-map.test.ts +++ b/tests/element-tag-map.test.ts @@ -1,4 +1,3 @@ -import { test, expect } from "vitest"; import { getElementByTag } from "../src/element-tag-map"; test("getElementByTag", () => { diff --git a/tests/fixtures.test.ts b/tests/fixtures.test.ts index 3756e3fd..54534aad 100644 --- a/tests/fixtures.test.ts +++ b/tests/fixtures.test.ts @@ -1,7 +1,6 @@ import fg from "fast-glob"; import fsp from "node:fs/promises"; import path from "node:path"; -import { describe, expect, test } from "vitest"; import ComponentParser from "../src/ComponentParser"; import Writer from "../src/writer/Writer"; import { writeTsDefinition } from "../src/writer/writer-ts-definitions"; diff --git a/tests/parse-exports.test.ts b/tests/parse-exports.test.ts index 8caf1149..39620eb7 100644 --- a/tests/parse-exports.test.ts +++ b/tests/parse-exports.test.ts @@ -1,4 +1,3 @@ -import { describe, expect, test } from "vitest"; import { parseExports } from "../src/parse-exports"; describe("parseExports", () => { diff --git a/tests/writer-ts-definitions.test.ts b/tests/writer-ts-definitions.test.ts index ec968875..4cfbed87 100644 --- a/tests/writer-ts-definitions.test.ts +++ b/tests/writer-ts-definitions.test.ts @@ -1,6 +1,5 @@ -import { describe, expect, test } from "vitest"; -import { ParsedComponent } from "../src/ComponentParser"; -import { ComponentDocApi } from "../src/rollup-plugin"; +import type { ParsedComponent } from "../src/ComponentParser"; +import type { ComponentDocApi } from "../src/rollup-plugin"; import { formatTsProps, getTypeDefs, writeTsDefinition } from "../src/writer/writer-ts-definitions"; describe("writerTsDefinition", () => { diff --git a/tsconfig.build.json b/tsconfig.build.json new file mode 100644 index 00000000..397ace4c --- /dev/null +++ b/tsconfig.build.json @@ -0,0 +1,8 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "declaration": true, + "module": "CommonJS", + }, + "include": ["src/**/*"] +} diff --git a/tsconfig.json b/tsconfig.json index a53f27e5..9f2d28dc 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,12 +1,13 @@ { "compilerOptions": { - "declaration": true, - "module": "CommonJS", + "module": "ESNext", + "target": "ESNext", "moduleResolution": "node", "outDir": "lib", "skipLibCheck": true, "strict": true, - "esModuleInterop": true + "esModuleInterop": true, + "types": ["vitest/globals"] }, - "include": ["src/**/*"] + "include": ["src/**/*", "tests/**/*"] } diff --git a/vite.config.ts b/vite.config.ts new file mode 100644 index 00000000..7593b61e --- /dev/null +++ b/vite.config.ts @@ -0,0 +1,8 @@ +/// +import { defineConfig } from "vite"; + +export default defineConfig({ + test: { + globals: true, + }, +});