From 36b875d85263382969f9d8c43b09ccfad34bf85d Mon Sep 17 00:00:00 2001 From: David Sanders Date: Sat, 22 Nov 2025 21:09:16 -0800 Subject: [PATCH] test: type check tests when running them --- package.json | 2 +- tests/block-parsers.spec.ts | 2 +- tests/helpers.spec.ts | 2 +- tests/markdown-helpers.spec.ts | 4 ++-- tests/tsconfig.json | 11 +++++++++++ 5 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 tests/tsconfig.json diff --git a/package.json b/package.json index c9f1d6c..9667738 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "prepublishOnly": "npx yarn build", "prettier:check": "prettier --list-different \"src/**/*.{ts,tsx}\"", "prettier:write": "prettier --write \"src/**/*.{ts,tsx}\"", - "test": "vitest run", + "test": "tsc --noEmit -p tests && vitest run", "prepare": "husky" }, "bin": { diff --git a/tests/block-parsers.spec.ts b/tests/block-parsers.spec.ts index 0da692f..f1572ce 100644 --- a/tests/block-parsers.spec.ts +++ b/tests/block-parsers.spec.ts @@ -1,7 +1,7 @@ import MarkdownIt from 'markdown-it'; import { describe, expect, it } from 'vitest'; -import { parseMethodBlocks } from '../src/block-parsers'; +import { parseMethodBlocks } from '../src/block-parsers.js'; describe('block parsers', () => { it('should parse a method', async () => { diff --git a/tests/helpers.spec.ts b/tests/helpers.spec.ts index e6820a2..e330e31 100644 --- a/tests/helpers.spec.ts +++ b/tests/helpers.spec.ts @@ -1,4 +1,4 @@ -import { extendError } from '../src/helpers'; +import { extendError } from '../src/helpers.js'; import chalk from 'chalk'; import { describe, expect, it } from 'vitest'; diff --git a/tests/markdown-helpers.spec.ts b/tests/markdown-helpers.spec.ts index df2aef8..f64d733 100644 --- a/tests/markdown-helpers.spec.ts +++ b/tests/markdown-helpers.spec.ts @@ -15,8 +15,8 @@ import { consumeTypedKeysList, findProcess, slugifyHeading, -} from '../src/markdown-helpers'; -import { DocumentationTag } from '../src/ParsedDocumentation'; +} from '../src/markdown-helpers.js'; +import { DocumentationTag } from '../src/ParsedDocumentation.js'; const getTokens = (md: string) => { const markdown = new MarkdownIt({ html: true }); diff --git a/tests/tsconfig.json b/tests/tsconfig.json new file mode 100644 index 0000000..beb5030 --- /dev/null +++ b/tests/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "incremental": false, + "noEmit": true, + "rootDir": ".." + }, + "include": [ + "." + ] +}