[READ-ONLY] Mirror of https://github.com/vitest-dev/vitest. Next generation testing framework powered by Vite. vitest.dev
test testing-tools vite
12

Configure Feed

Select the types of activity you want to include in your feed.

fix(vitest,runner): simplify `test.extend` type exports (#6707)

authored by

Hiroshi Ogawa and committed by
GitHub
(Oct 15, 2024, 11:39 AM +0200) e5c388f0 62ac4eb1

+55 -3
+6
pnpm-lock.yaml
··· 1259 1259 specifier: latest 1260 1260 version: 9.2.1 1261 1261 1262 + test/dts-fixture: 1263 + devDependencies: 1264 + vitest: 1265 + specifier: workspace:* 1266 + version: link:../../packages/vitest 1267 + 1262 1268 test/global-setup: 1263 1269 devDependencies: 1264 1270 vitest:
+13
test/dts-fixture/package.json
··· 1 + { 2 + "name": "@vitest/test-dts-fixture", 3 + "type": "module", 4 + "private": true, 5 + "scripts": { 6 + "build": "rm -rf dist && tsc -p tsconfig.json", 7 + "check": "tsc -p tsconfig.check.json", 8 + "test": "pnpm build && pnpm check" 9 + }, 10 + "devDependencies": { 11 + "vitest": "workspace:*" 12 + } 13 + }
+12
test/dts-fixture/tsconfig.check.json
··· 1 + { 2 + "compilerOptions": { 3 + "target": "ESNext", 4 + "module": "NodeNext", 5 + "moduleResolution": "NodeNext", 6 + "types": [], 7 + "strict": true, 8 + "noEmit": true, 9 + "verbatimModuleSyntax": true 10 + }, 11 + "include": ["dist"] 12 + }
+14
test/dts-fixture/tsconfig.json
··· 1 + { 2 + "compilerOptions": { 3 + "target": "ESNext", 4 + "module": "ESNext", 5 + "moduleResolution": "Bundler", 6 + "strict": true, 7 + "declaration": true, 8 + "declarationMap": true, 9 + "outDir": "dist", 10 + "sourceMap": true, 11 + "verbatimModuleSyntax": true 12 + }, 13 + "include": ["src"] 14 + }
+7
test/dts-fixture/src/repro.ts
··· 1 + import { test } from 'vitest' 2 + 3 + export const myTest = test.extend<{ now: number }>({ 4 + now: async ({}, use) => { 5 + await use(Date.now()) 6 + }, 7 + })
+3 -3
packages/runner/src/types/tasks.ts
··· 411 411 runIf: (condition: any) => ChainableTestAPI<ExtraContext> 412 412 } 413 413 414 - export type CustomAPI<ExtraContext = object> = ChainableTestAPI<ExtraContext> & 414 + export type TestAPI<ExtraContext = object> = ChainableTestAPI<ExtraContext> & 415 415 ExtendedAPI<ExtraContext> & { 416 416 extend: <T extends Record<string, any> = object>( 417 417 fixtures: Fixtures<T, ExtraContext> 418 - ) => CustomAPI<{ 418 + ) => TestAPI<{ 419 419 [K in keyof T | keyof ExtraContext]: K extends keyof T 420 420 ? T[K] 421 421 : K extends keyof ExtraContext ··· 424 424 }> 425 425 } 426 426 427 - export type TestAPI<ExtraContext = object> = CustomAPI<ExtraContext> 427 + export type { TestAPI as CustomAPI } 428 428 429 429 export interface FixtureOptions { 430 430 /**