Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"test:browser:playwright": "pnpm -C test/browser run test:playwright"
},
"devDependencies": {
"@antfu/eslint-config": "^5.4.1",
"@antfu/eslint-config": "^6.2.0",
"@antfu/ni": "^27.0.1",
"@playwright/test": "^1.56.1",
"@rollup/plugin-commonjs": "^28.0.9",
Expand Down
2 changes: 1 addition & 1 deletion packages/browser-webdriverio/src/commands/keyboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export interface KeyboardState {

export const keyboard: UserEventCommand<(
text: string,
state: KeyboardState
state: KeyboardState,
) => Promise<{ unreleased: string[] }>> = async (
context,
text,
Expand Down
6 changes: 3 additions & 3 deletions packages/browser/src/node/commands/screenshotMatcher/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ export interface Codec<
> {
decode: (
buffer: TypedArray,
options: DecoderOptions
options: DecoderOptions,
) => Promisable<{
data: TypedArray
metadata: DecoderMetadata & BaseMetadata
}>
encode: (
image: { data: TypedArray; metadata: BaseMetadata },
options: EncoderOptions
options: EncoderOptions,
) => Promisable<TypedArray>
}

Expand All @@ -45,7 +45,7 @@ export type Comparator<Options extends Record<string, unknown>> = (
* Note that the comparator might choose to ignore the flag, so a diff image is not guaranteed.
*/
createDiff: boolean
} & Options
} & Options,
) => Promisable<{ pass: boolean; diff: TypedArray | null; message: string | null }>

type CustomComparatorsToRegister = {
Expand Down
6 changes: 3 additions & 3 deletions packages/browser/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ export interface WebSocketBrowserHandlers {
debug: (...args: string[]) => void
resolveId: (
id: string,
importer?: string
importer?: string,
) => Promise<ServerIdResolution | null>
triggerCommand: <T>(
sessionId: string,
command: string,
testPath: string | undefined,
payload: unknown[]
payload: unknown[],
) => Promise<T>
resolveMock: (
id: string,
Expand All @@ -46,7 +46,7 @@ export interface WebSocketBrowserHandlers {
) => Promise<ServerMockResolution>
invalidate: (ids: string[]) => void
getBrowserFileSourceMap: (
id: string
id: string,
) => SourceMap | null | { mappings: '' } | undefined
wdioSwitchContext: (direction: 'iframe' | 'parent') => void

Expand Down
10 changes: 5 additions & 5 deletions packages/expect/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ export type Tester = (
this: TesterContext,
a: any,
b: any,
customTesters: Array<Tester>
customTesters: Array<Tester>,
) => boolean | undefined

export interface TesterContext {
equals: (
a: unknown,
b: unknown,
customTesters?: Array<Tester>,
strictCheck?: boolean
strictCheck?: boolean,
) => boolean
}
export type { DiffOptions } from '@vitest/utils/diff'
Expand All @@ -52,7 +52,7 @@ export interface MatcherState {
a: unknown,
b: unknown,
customTesters?: Array<Tester>,
strictCheck?: boolean
strictCheck?: boolean,
) => boolean
expand?: boolean
expectedAssertionsNumber?: number | null
Expand Down Expand Up @@ -399,7 +399,7 @@ export interface JestAssertion<T = any> extends jest.Matchers<void, T>, CustomMa
*/
toHaveProperty: <E>(
property: string | (string | number)[],
value?: E
value?: E,
) => void

/**
Expand Down Expand Up @@ -684,7 +684,7 @@ export interface Assertion<T = any>
| 'object'
| 'string'
| 'symbol'
| 'undefined'
| 'undefined',
) => void

/**
Expand Down
18 changes: 9 additions & 9 deletions packages/mocker/src/browser/hints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ export function createCompilerHints(options?: CompilerHintsOptions): ModuleMocke
// @ts-expect-error injected by the plugin
? globalThis[globalThisAccessor]
: new Proxy(
{} as any,
{
get(_, name) {
throw new Error(
'Vitest mocker was not initialized in this environment. '
+ `vi.${String(name)}() is forbidden.`,
)
{} as any,
{
get(_, name) {
throw new Error(
'Vitest mocker was not initialized in this environment. '
+ `vi.${String(name)}() is forbidden.`,
)
},
},
},
)
)
}

return {
Expand Down
2 changes: 1 addition & 1 deletion packages/mocker/src/browser/mocker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ export interface ModuleMockerRPC {
resolveMock: (
id: string,
importer: string,
options: { mock: 'spy' | 'factory' | 'auto' }
options: { mock: 'spy' | 'factory' | 'auto' },
) => Promise<ResolveMockResult>
}

Expand Down
2 changes: 1 addition & 1 deletion packages/mocker/src/node/esmWalker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ interface Visitors {
onIdentifier?: (
node: Positioned<Identifier>,
info: IdentifierInfo,
parentStack: Node[]
parentStack: Node[],
) => void
onImportMeta?: (node: Node) => void
onDynamicImport?: (node: Positioned<ImportExpression>) => void
Expand Down
2 changes: 1 addition & 1 deletion packages/mocker/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
type Awaitable<T> = T | PromiseLike<T>

export type ModuleMockFactoryWithHelper<M = unknown> = (
importOriginal: <T extends M = M>() => Promise<T>
importOriginal: <T extends M = M>() => Promise<T>,
) => Awaitable<Partial<M>>
export type ModuleMockFactory = () => any
export interface ModuleMockOptions {
Expand Down
2 changes: 1 addition & 1 deletion packages/runner/src/fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ function resolveFixtureValue(
async function resolveFixtureFunction(
fixtureFn: (
context: unknown,
useFn: (arg: unknown) => Promise<void>
useFn: (arg: unknown) => Promise<void>,
) => Promise<void>,
context: unknown,
cleanupFnArray: (() => void | Promise<void>)[],
Expand Down
2 changes: 1 addition & 1 deletion packages/runner/src/suite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@ function createTest(
> & { fixtures?: FixtureItem[] },
title: string,
optionsOrFn?: TestOptions | TestFunction,
optionsOrTest?: number | TestFunction
optionsOrTest?: number | TestFunction,
) => void,
context?: Record<string, any>,
) {
Expand Down
6 changes: 3 additions & 3 deletions packages/runner/src/types/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export interface VitestRunner {
*/
onBeforeTryTask?: (
test: Test,
options: { retry: number; repeats: number }
options: { retry: number; repeats: number },
) => unknown
/**
* When the task has finished running, but before cleanup hooks are called
Expand All @@ -104,15 +104,15 @@ export interface VitestRunner {
*/
onAfterTryTask?: (
test: Test,
options: { retry: number; repeats: number }
options: { retry: number; repeats: number },
) => unknown
/**
* Called after the retry resolution happend. Unlike `onAfterTryTask`, the test now has a new state.
* All `after` hooks were also called by this point.
*/
onAfterRetryTask?: (
test: Test,
options: { retry: number; repeats: number }
options: { retry: number; repeats: number },
) => unknown

/**
Expand Down
10 changes: 5 additions & 5 deletions packages/runner/src/types/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ export interface TestAnnotation {
export type Task = Test | Suite | File

export type TestFunction<ExtraContext = object> = (
context: TestContext & ExtraContext
context: TestContext & ExtraContext,
) => Awaitable<any> | void

// jest's ExtractEachCallbackArgs
Expand Down Expand Up @@ -493,7 +493,7 @@ interface Hooks<ExtraContext> {
export type TestAPI<ExtraContext = object> = ChainableTestAPI<ExtraContext>
& ExtendedAPI<ExtraContext> & Hooks<ExtraContext> & {
extend: <T extends Record<string, any> = object>(
fixtures: Fixtures<T, ExtraContext>
fixtures: Fixtures<T, ExtraContext>,
) => TestAPI<{
[K in keyof T | keyof ExtraContext]: K extends keyof T
? T[K]
Expand All @@ -502,7 +502,7 @@ export type TestAPI<ExtraContext = object> = ChainableTestAPI<ExtraContext>
: never;
}>
scoped: (
fixtures: Fixtures<Partial<ExtraContext>>
fixtures: Fixtures<Partial<ExtraContext>>,
) => void
}

Expand Down Expand Up @@ -531,7 +531,7 @@ export interface FixtureOptions {
export type Use<T> = (value: T) => Promise<void>
export type FixtureFn<T, K extends keyof T, ExtraContext> = (
context: Omit<T, K> & ExtraContext,
use: Use<T[K]>
use: Use<T[K]>,
) => Promise<void>
export type Fixture<T, K extends keyof T, ExtraContext = object> = ((
...args: any
Expand Down Expand Up @@ -652,7 +652,7 @@ export interface SuiteCollector<ExtraContext = object> {
}

export type SuiteFactory<ExtraContext = object> = (
test: TestAPI<ExtraContext>
test: TestAPI<ExtraContext>,
) => Awaitable<void>

export interface RuntimeContext {
Expand Down
6 changes: 3 additions & 3 deletions packages/spy/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,16 +212,16 @@ export function fn<T extends Procedure | Constructable = Procedure>(
export function spyOn<T extends object, S extends Properties<Required<T>>>(
object: T,
key: S,
accessor: 'get'
accessor: 'get',
): Mock<() => T[S]>
export function spyOn<T extends object, G extends Properties<Required<T>>>(
object: T,
key: G,
accessor: 'set'
accessor: 'set',
): Mock<(arg: T[G]) => void>
export function spyOn<T extends object, M extends Classes<Required<T>> | Methods<Required<T>>>(
object: T,
key: M
key: M,
): Required<T>[M] extends Constructable | Procedure
? Mock<Required<T>[M]>
: never
Expand Down
6 changes: 3 additions & 3 deletions packages/utils/src/diff/getAlignedDiffs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ class ChangeBuffer {
this.lines.push(
this.line.length !== 1
? new Diff(
this.op,
concatenateRelevantDiffs(this.op, this.line, this.changeColor),
)
this.op,
concatenateRelevantDiffs(this.op, this.line, this.changeColor),
)
: this.line[0][0] === this.op
? this.line[0] // can use instance
: new Diff(this.op, this.line[0][1]), // was common diff
Expand Down
6 changes: 3 additions & 3 deletions packages/vitest/src/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ export interface WebSocketHandlers {
getModuleGraph: (
projectName: string,
id: string,
browser?: boolean
browser?: boolean,
) => Promise<ModuleGraphData>
getTransformResult: (
projectName: string,
id: string,
browser?: boolean
browser?: boolean,
) => Promise<TransformResultWithSource | undefined>
readTestFile: (id: string) => Promise<string | null>
saveTestFile: (id: string, content: string) => Promise<void>
Expand All @@ -57,7 +57,7 @@ export interface WebSocketEvents {
onFinished?: (
files: File[],
errors: unknown[],
coverage?: unknown
coverage?: unknown,
) => Awaitable<void>
onTestAnnotate?: (testId: string, annotation: TestAnnotation) => Awaitable<void>
onTaskUpdate?: (packs: TaskResultPack[], events: TaskEventPack[]) => Awaitable<void>
Expand Down
30 changes: 15 additions & 15 deletions packages/vitest/src/integrations/vi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ export interface VitestUtils {
* @returns Fully mocked module
*/
importMock: <T = ESModuleExports>(
path: string
path: string,
) => Promise<MaybeMockedDeep<T>>

/**
Expand Down Expand Up @@ -327,19 +327,19 @@ export interface VitestUtils {
& (<T>(item: T, deep: true) => MaybeMockedDeep<T>)
& (<T>(
item: T,
options: { partial?: false; deep?: false }
options: { partial?: false; deep?: false },
) => MaybeMocked<T>)
& (<T>(
item: T,
options: { partial?: false; deep: true }
options: { partial?: false; deep: true },
) => MaybeMockedDeep<T>)
& (<T>(
item: T,
options: { partial: true; deep?: false }
options: { partial: true; deep?: false },
) => MaybePartiallyMocked<T>)
& (<T>(
item: T,
options: { partial: true; deep: true }
options: { partial: true; deep: true },
) => MaybePartiallyMockedDeep<T>)
& (<T>(item: T) => MaybeMocked<T>)

Expand Down Expand Up @@ -388,7 +388,7 @@ export interface VitestUtils {
*/
stubEnv: <T extends string>(
name: T,
value: T extends 'PROD' | 'DEV' | 'SSR' ? boolean : string | undefined
value: T extends 'PROD' | 'DEV' | 'SSR' ? boolean : string | undefined,
) => VitestUtils

/**
Expand Down Expand Up @@ -766,16 +766,16 @@ function _mocker(): VitestMocker {
// @ts-expect-error injected by vite-nide
? __vitest_mocker__
: new Proxy(
{} as any,
{
get(_, name) {
throw new Error(
'Vitest mocker was not initialized in this environment. '
+ `vi.${String(name)}() is forbidden.`,
)
{} as any,
{
get(_, name) {
throw new Error(
'Vitest mocker was not initialized in this environment. '
+ `vi.${String(name)}() is forbidden.`,
)
},
},
},
)
)
}

function getImporter(name: string) {
Expand Down
2 changes: 1 addition & 1 deletion packages/vitest/src/node/pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const suppressWarningsPath = resolve(rootDir, './suppress-warnings.cjs')

type RunWithFiles = (
files: TestSpecification[],
invalidates?: string[]
invalidates?: string[],
) => Promise<void>

export interface ProcessPool {
Expand Down
2 changes: 1 addition & 1 deletion packages/vitest/src/node/types/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ export interface ProjectBrowser {
cb: BrowserCommand<
Parameters<BrowserCommands[K]>,
ReturnType<BrowserCommands[K]>
>
>,
) => void
triggerCommand: <K extends keyof BrowserCommands>(
name: K,
Expand Down
Loading
Loading