chore(deps): update @antfu/eslint-config v3.8.0 (#6751)

This commit is contained in:
Hiroshi Ogawa 2024-10-23 20:18:42 +09:00 committed by GitHub
parent 9d9bad5b10
commit de74785e05
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
421 changed files with 1867 additions and 1825 deletions

View File

@ -1,6 +1,6 @@
<script setup lang="ts">
import { computed, effectScope, onMounted, ref } from 'vue'
import { until, useElementVisibility } from '@vueuse/core'
import { computed, effectScope, onMounted, ref } from 'vue'
const el = ref<HTMLDivElement>()
const state = ref(0)

View File

@ -1,8 +1,9 @@
import { defineConfig } from 'vitepress'
import { withPwa } from '@vite-pwa/vitepress'
import { transformerTwoslash } from '@shikijs/vitepress-twoslash'
import { withPwa } from '@vite-pwa/vitepress'
import { defineConfig } from 'vitepress'
import { tabsMarkdownPlugin } from 'vitepress-plugin-tabs'
import { version } from '../../package.json'
import { teamMembers } from './contributors'
import {
contributing,
discord,
@ -18,7 +19,6 @@ import {
} from './meta'
import { pwa } from './scripts/pwa'
import { transformHead } from './scripts/transformHead'
import { teamMembers } from './contributors'
export default ({ mode }: { mode: string }) => {
return withPwa(defineConfig({

View File

@ -164,4 +164,4 @@ const plainTeamEmeritiMembers: CoreTeam[] = [
const teamMembers = plainTeamMembers.map(tm => createLinks(tm))
const teamEmeritiMembers = plainTeamEmeritiMembers.map(tm => createLinks(tm))
export { teamMembers, teamEmeritiMembers }
export { teamEmeritiMembers, teamMembers }

View File

@ -1,7 +1,7 @@
import type { CLIOption, CLIOptions } from '../../../packages/vitest/src/node/cli/cli-config'
import { writeFileSync } from 'node:fs'
import { dirname, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
import type { CLIOption, CLIOptions } from '../../../packages/vitest/src/node/cli/cli-config'
import { cliOptionsConfig } from '../../../packages/vitest/src/node/cli/cli-config'
const docsDir = resolve(dirname(fileURLToPath(import.meta.url)), '../..')

View File

@ -11,7 +11,7 @@ async function download(url: string, fileName: string) {
if (existsSync(fileName)) {
return
}
// eslint-disable-next-line no-console
console.log('downloading', fileName)
try {
const image = await (await fetch(url)).arrayBuffer()

View File

@ -1,8 +1,8 @@
import type { PwaOptions } from '@vite-pwa/vitepress'
import {
githubusercontentRegex,
pwaFontStylesRegex,
pwaFontsRegex,
pwaFontStylesRegex,
vitestDescription,
vitestName,
vitestShortName,

View File

@ -1,14 +1,14 @@
import { h } from 'vue'
import type { Theme } from 'vitepress'
import DefaultTheme from 'vitepress/theme'
import TwoslashFloatingVue from '@shikijs/vitepress-twoslash/client'
import { inBrowser } from 'vitepress'
import DefaultTheme from 'vitepress/theme'
import { enhanceAppWithTabs } from 'vitepress-plugin-tabs/client'
import { h } from 'vue'
import HomePage from '../components/HomePage.vue'
import Version from '../components/Version.vue'
import '../style/main.css'
import '../style/vars.css'
import 'uno.css'
import TwoslashFloatingVue from '@shikijs/vitepress-twoslash/client'
import { enhanceAppWithTabs } from 'vitepress-plugin-tabs/client'
import HomePage from '../components/HomePage.vue'
import Version from '../components/Version.vue'
import '@shikijs/vitepress-twoslash/style.css'
if (inBrowser) {

View File

@ -65,7 +65,7 @@ To communicate between different processes, you can create methods object using
```ts
import { createBirpc } from 'birpc'
import { parse, stringify } from 'flatted'
import { WorkspaceProject, createMethodsRPC } from 'vitest/node'
import { createMethodsRPC, WorkspaceProject } from 'vitest/node'
function createRpc(project: WorkspaceProject, wss: WebSocketServer) {
return createBirpc(

View File

@ -250,7 +250,7 @@ A task is an object that is part of a suite. It is automatically added to the cu
// ./utils/custom.js
import { createTaskCollector, getCurrentSuite, setFn } from 'vitest/suite'
export { describe, beforeAll, afterAll } from 'vitest'
export { afterAll, beforeAll, describe } from 'vitest'
// this function will be called during collection phase:
// don't call function handler here, add it to suite tasks

View File

@ -443,7 +443,7 @@ You can use it like below in your [setup file](/config/#setupfiles)
```js
import { afterAll, afterEach, beforeAll } from 'vitest'
import { setupServer } from 'msw/node'
import { HttpResponse, graphql, http } from 'msw'
import { graphql, http, HttpResponse } from 'msw'
const posts = [
{

View File

@ -1,8 +1,8 @@
import type { Plugin } from 'vite'
import { defineConfig } from 'vite'
import Components from 'unplugin-vue-components/vite'
import Unocss from 'unocss/vite'
import { presetAttributify, presetIcons, presetUno } from 'unocss'
import Unocss from 'unocss/vite'
import Components from 'unplugin-vue-components/vite'
import { defineConfig } from 'vite'
export default defineConfig({
optimizeDeps: {

View File

@ -98,8 +98,10 @@ export default antfu(
files: [
`docs/${GLOB_SRC}`,
`**/*.md`,
`**/*.md/${GLOB_SRC}`,
],
rules: {
'perfectionist/sort-imports': 'off',
'style/max-statements-per-line': 'off',
'import/newline-after-import': 'off',
'import/first': 'off',
@ -122,6 +124,7 @@ export default antfu(
`test/${GLOB_SRC}`,
],
rules: {
'antfu/no-top-level-await': 'off',
'unicorn/consistent-function-scoping': 'off',
},
},

View File

@ -1,8 +1,8 @@
import { afterAll, expect, test } from 'vitest'
import supertest from 'supertest'
import { afterAll, expect, test } from 'vitest'
import app from '../src/app'
import { usersData } from '../mockData'
import app from '../src/app'
test('with HTTP injection', async () => {
const response = await app.inject({

View File

@ -1,4 +1,4 @@
import { LitElement, css, html } from 'lit'
import { css, html, LitElement } from 'lit'
import { customElement, property } from 'lit/decorators.js'
/**

View File

@ -1,5 +1,5 @@
import { beforeEach, describe, expect, it } from 'vitest'
import { page } from '@vitest/browser/context'
import { beforeEach, describe, expect, it } from 'vitest'
import '../src/my-button.js'

View File

@ -1,7 +1,7 @@
import React from 'react'
import { expect, test } from 'vitest'
import { render, screen } from '@testing-library/react'
import { userEvent } from '@testing-library/user-event'
import React from 'react'
import { expect, test } from 'vitest'
import Link from '../components/Link.jsx'
test('Link changes the state when hovered', async () => {

View File

@ -1,8 +1,8 @@
import { afterAll, expect, test } from 'vitest'
import supertest from 'supertest'
import { afterAll, expect, test } from 'vitest'
import app from '../src/app'
import { usersData } from '../mockData'
import app from '../src/app'
test('with HTTP injection', async () => {
const response = await app.inject({

View File

@ -36,7 +36,7 @@
"test:browser:playwright": "pnpm -C test/browser run test:playwright"
},
"devDependencies": {
"@antfu/eslint-config": "3.0.0",
"@antfu/eslint-config": "^3.8.0",
"@antfu/ni": "^0.23.0",
"@playwright/test": "^1.48.0",
"@rollup/plugin-commonjs": "^28.0.0",

View File

@ -1,10 +1,10 @@
import { createRequire } from 'node:module'
import esbuild from 'rollup-plugin-esbuild'
import dts from 'rollup-plugin-dts'
import resolve from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import json from '@rollup/plugin-json'
import resolve from '@rollup/plugin-node-resolve'
import { defineConfig } from 'rollup'
import dts from 'rollup-plugin-dts'
import esbuild from 'rollup-plugin-esbuild'
const require = createRequire(import.meta.url)
const pkg = require('./package.json')

View File

@ -1,5 +1,5 @@
import type { CancelReason } from '@vitest/runner'
import type { MockedModuleSerialized } from '@vitest/mocker'
import type { CancelReason } from '@vitest/runner'
import { getBrowserState } from './utils'
export interface IframeDoneEvent {

View File

@ -1,7 +1,7 @@
import type { CancelReason } from '@vitest/runner'
import type { WebSocketBrowserEvents, WebSocketBrowserHandlers } from '../node/types'
import { type BirpcReturn, createBirpc } from 'birpc'
import { parse, stringify } from 'flatted'
import type { WebSocketBrowserEvents, WebSocketBrowserHandlers } from '../node/types'
import { getBrowserState } from './utils'
const PAGE_TYPE = getBrowserState().type

View File

@ -1,11 +1,11 @@
import { channel, client } from '@vitest/browser/client'
import { generateHash } from '@vitest/runner/utils'
import { type GlobalChannelIncomingEvent, type IframeChannelEvent, type IframeChannelIncomingEvent, globalChannel } from '@vitest/browser/client'
import { relative } from 'pathe'
import type { SerializedConfig } from 'vitest'
import { getBrowserState, getConfig } from './utils'
import { getUiAPI } from './ui'
import { channel, client } from '@vitest/browser/client'
import { globalChannel, type GlobalChannelIncomingEvent, type IframeChannelEvent, type IframeChannelIncomingEvent } from '@vitest/browser/client'
import { generateHash } from '@vitest/runner/utils'
import { relative } from 'pathe'
import { createModuleMockerInterceptor } from './tester/msw'
import { getUiAPI } from './ui'
import { getBrowserState, getConfig } from './utils'
const url = new URL(location.href)
const ID_ALL = '__vitest_all__'

View File

@ -1,6 +1,6 @@
import type { RunnerTask } from 'vitest'
import type { BrowserRPC } from '@vitest/browser/client'
import type { Options as TestingLibraryOptions, UserEvent as TestingLibraryUserEvent } from '@testing-library/user-event'
import type { BrowserRPC } from '@vitest/browser/client'
import type { RunnerTask } from 'vitest'
import type {
BrowserPage,
Locator,

View File

@ -1,6 +1,6 @@
import * as matchers from '@testing-library/jest-dom/matchers'
import type { Locator } from '@vitest/browser/context'
import type { ExpectPollOptions } from 'vitest'
import * as matchers from '@testing-library/jest-dom/matchers'
import { chai, expect } from 'vitest'
export async function setupExpectDom() {

View File

@ -1,3 +1,4 @@
import type { BrowserRPC } from '@vitest/browser/client'
import type {
LocatorByRoleOptions,
LocatorOptions,
@ -7,11 +8,10 @@ import type {
UserEventFillOptions,
UserEventHoverOptions,
} from '@vitest/browser/context'
import type { WorkerGlobalState } from 'vitest'
import type { BrowserRunnerState } from '../../utils'
import { page, server } from '@vitest/browser/context'
import type { BrowserRPC } from '@vitest/browser/client'
import {
Ivya,
type ParsedSelector,
getByAltTextSelector,
getByLabelSelector,
getByPlaceholderSelector,
@ -19,9 +19,9 @@ import {
getByTestIdSelector,
getByTextSelector,
getByTitleSelector,
Ivya,
type ParsedSelector,
} from 'ivya'
import type { WorkerGlobalState } from 'vitest'
import type { BrowserRunnerState } from '../../utils'
import { getBrowserState, getWorkerState } from '../../utils'
import { getElementError } from '../public-utils'

View File

@ -1,5 +1,5 @@
import { page, server } from '@vitest/browser/context'
import { userEvent } from '@testing-library/user-event'
import { page, server } from '@vitest/browser/context'
import {
getByAltTextSelector,
getByLabelSelector,

View File

@ -1,10 +1,10 @@
import { channel } from '@vitest/browser/client'
import type {
IframeChannelEvent,
IframeMockFactoryRequestEvent,
IframeMockingDoneEvent,
} from '@vitest/browser/client'
import type { MockedModuleSerialized } from '@vitest/mocker'
import { channel } from '@vitest/browser/client'
import { ManualMockedModule } from '@vitest/mocker'
import { ModuleMockerMSWInterceptor } from '@vitest/mocker/browser'
import { nanoid } from '@vitest/utils'

View File

@ -1,6 +1,6 @@
import { type Locator, type LocatorSelectors, page } from '@vitest/browser/context'
import { type StringifyOptions, stringify } from 'vitest/utils'
import { asLocator } from 'ivya'
import { stringify, type StringifyOptions } from 'vitest/utils'
export function getElementLocatorSelectors(element: Element): LocatorSelectors {
const locator = page.elementLocator(element)

View File

@ -1,5 +1,5 @@
import { getSafeTimers } from 'vitest/utils'
import type { VitestBrowserClient } from '@vitest/browser/client'
import { getSafeTimers } from 'vitest/utils'
const { get } = Reflect

View File

@ -1,15 +1,15 @@
import type { CancelReason, File, Suite, Task, TaskResultPack, VitestRunner } from '@vitest/runner'
import type { SerializedConfig, WorkerGlobalState } from 'vitest'
import type { VitestExecutor } from 'vitest/execute'
import { NodeBenchmarkRunner, VitestTestRunner } from 'vitest/runners'
import { loadDiffConfig, loadSnapshotSerializers, takeCoverageInsideWorker } from 'vitest/browser'
import { TraceMap, originalPositionFor } from 'vitest/utils'
import { page, userEvent } from '@vitest/browser/context'
import { globalChannel } from '@vitest/browser/client'
import { executor } from '../utils'
import { VitestBrowserSnapshotEnvironment } from './snapshot'
import { rpc } from './rpc'
import type { VitestBrowserClientMocker } from './mocker'
import { globalChannel } from '@vitest/browser/client'
import { page, userEvent } from '@vitest/browser/context'
import { loadDiffConfig, loadSnapshotSerializers, takeCoverageInsideWorker } from 'vitest/browser'
import { NodeBenchmarkRunner, VitestTestRunner } from 'vitest/runners'
import { originalPositionFor, TraceMap } from 'vitest/utils'
import { executor } from '../utils'
import { rpc } from './rpc'
import { VitestBrowserSnapshotEnvironment } from './snapshot'
interface BrowserRunnerOptions {
config: SerializedConfig

View File

@ -1,6 +1,6 @@
import type { SnapshotEnvironment } from 'vitest/snapshot'
import { type ParsedStack, TraceMap, originalPositionFor } from 'vitest/utils'
import type { VitestBrowserClient } from '@vitest/browser/client'
import type { SnapshotEnvironment } from 'vitest/snapshot'
import { originalPositionFor, type ParsedStack, TraceMap } from 'vitest/utils'
export class VitestBrowserSnapshotEnvironment implements SnapshotEnvironment {
private sourceMaps = new Map<string, any>()

View File

@ -1,6 +1,6 @@
import type { BrowserRPC } from '@vitest/browser/client'
import type { WorkerGlobalState } from 'vitest'
import { parse } from 'flatted'
import type { BrowserRPC } from '@vitest/browser/client'
import { getBrowserState } from '../utils'
const config = getBrowserState().config

View File

@ -1,14 +1,14 @@
import { SpyModule, collectTests, setupCommonEnv, startCoverageInsideWorker, startTests, stopCoverageInsideWorker } from 'vitest/browser'
import { page, userEvent } from '@vitest/browser/context'
import type { IframeMockEvent, IframeMockInvalidateEvent, IframeUnmockEvent } from '@vitest/browser/client'
import { channel, client, onCancel, waitForChannel } from '@vitest/browser/client'
import { page, userEvent } from '@vitest/browser/context'
import { collectTests, setupCommonEnv, SpyModule, startCoverageInsideWorker, startTests, stopCoverageInsideWorker } from 'vitest/browser'
import { executor, getBrowserState, getConfig, getWorkerState } from '../utils'
import { setupDialogsSpy } from './dialog'
import { setupExpectDom } from './expect-element'
import { setupConsoleLogSpy } from './logger'
import { VitestBrowserClientMocker } from './mocker'
import { createSafeRpc } from './rpc'
import { browserHashMap, initiateRunner } from './runner'
import { VitestBrowserClientMocker } from './mocker'
import { setupExpectDom } from './expect-element'
const cleanupSymbol = Symbol.for('vitest:component-cleanup')

View File

@ -1,8 +1,8 @@
import { fileURLToPath } from 'node:url'
import fs from 'node:fs'
import { defineConfig } from 'vite'
import { fileURLToPath } from 'node:url'
import { resolve } from 'pathe'
import { globSync } from 'tinyglobby'
import { defineConfig } from 'vite'
export default defineConfig({
server: {
@ -34,7 +34,7 @@ export default defineConfig({
plugins: [
{
name: 'copy-ui-plugin',
/* eslint-disable no-console */
closeBundle: async () => {
const root = resolve(
fileURLToPath(import.meta.url),

View File

@ -1,7 +1,7 @@
import type { UserEvent } from '../../../context'
import type { UserEventCommand } from './utils'
import { PlaywrightBrowserProvider } from '../providers/playwright'
import { WebdriverBrowserProvider } from '../providers/webdriver'
import type { UserEventCommand } from './utils'
export const clear: UserEventCommand<UserEvent['clear']> = async (
context,

View File

@ -1,7 +1,7 @@
import type { UserEvent } from '../../../context'
import type { UserEventCommand } from './utils'
import { PlaywrightBrowserProvider } from '../providers/playwright'
import { WebdriverBrowserProvider } from '../providers/webdriver'
import type { UserEventCommand } from './utils'
export const click: UserEventCommand<UserEvent['click']> = async (
context,

View File

@ -1,7 +1,7 @@
import type { UserEvent } from '../../../context'
import type { UserEventCommand } from './utils'
import { PlaywrightBrowserProvider } from '../providers/playwright'
import { WebdriverBrowserProvider } from '../providers/webdriver'
import type { UserEventCommand } from './utils'
export const dragAndDrop: UserEventCommand<UserEvent['dragAndDrop']> = async (
context,

View File

@ -1,7 +1,7 @@
import type { UserEvent } from '../../../context'
import type { UserEventCommand } from './utils'
import { PlaywrightBrowserProvider } from '../providers/playwright'
import { WebdriverBrowserProvider } from '../providers/webdriver'
import type { UserEventCommand } from './utils'
export const fill: UserEventCommand<UserEvent['fill']> = async (
context,

View File

@ -1,9 +1,9 @@
import type { BrowserCommand, WorkspaceProject } from 'vitest/node'
import type { BrowserCommands } from '../../../context'
import fs, { promises as fsp } from 'node:fs'
import { basename, dirname, resolve } from 'node:path'
import { isFileServingAllowed } from 'vitest/node'
import type { BrowserCommand, WorkspaceProject } from 'vitest/node'
import mime from 'mime/lite'
import type { BrowserCommands } from '../../../context'
import { isFileServingAllowed } from 'vitest/node'
function assertFileAccess(path: string, project: WorkspaceProject) {
if (

View File

@ -1,7 +1,7 @@
import type { UserEvent } from '../../../context'
import type { UserEventCommand } from './utils'
import { PlaywrightBrowserProvider } from '../providers/playwright'
import { WebdriverBrowserProvider } from '../providers/webdriver'
import type { UserEventCommand } from './utils'
export const hover: UserEventCommand<UserEvent['hover']> = async (
context,

View File

@ -1,20 +1,20 @@
import { click, dblClick, tripleClick } from './click'
import { type } from './type'
import { clear } from './clear'
import { fill } from './fill'
import { selectOptions } from './select'
import { tab } from './tab'
import { keyboard, keyboardCleanup } from './keyboard'
import { click, dblClick, tripleClick } from './click'
import { dragAndDrop } from './dragAndDrop'
import { hover } from './hover'
import { upload } from './upload'
import { fill } from './fill'
import {
_fileInfo,
readFile,
removeFile,
writeFile,
} from './fs'
import { hover } from './hover'
import { keyboard, keyboardCleanup } from './keyboard'
import { screenshot } from './screenshot'
import { selectOptions } from './select'
import { tab } from './tab'
import { type } from './type'
import { upload } from './upload'
export default {
readFile,

View File

@ -1,9 +1,9 @@
import { parseKeyDef } from '@testing-library/user-event/dist/esm/keyboard/parseKeyDef.js'
import { defaultKeyMap } from '@testing-library/user-event/dist/esm/keyboard/keyMap.js'
import type { BrowserProvider } from 'vitest/node'
import type { UserEventCommand } from './utils'
import { defaultKeyMap } from '@testing-library/user-event/dist/esm/keyboard/keyMap.js'
import { parseKeyDef } from '@testing-library/user-event/dist/esm/keyboard/parseKeyDef.js'
import { PlaywrightBrowserProvider } from '../providers/playwright'
import { WebdriverBrowserProvider } from '../providers/webdriver'
import type { UserEventCommand } from './utils'
export interface KeyboardState {
unreleased: string[]

View File

@ -1,8 +1,8 @@
import type { BrowserCommand, ResolvedConfig } from 'vitest/node'
import type { ScreenshotOptions } from '../../../context'
import { mkdir } from 'node:fs/promises'
import { normalize } from 'node:path'
import type { BrowserCommand, ResolvedConfig } from 'vitest/node'
import { basename, dirname, relative, resolve } from 'pathe'
import type { ScreenshotOptions } from '../../../context'
import { PlaywrightBrowserProvider } from '../providers/playwright'
import { WebdriverBrowserProvider } from '../providers/webdriver'

View File

@ -1,8 +1,8 @@
import type { ElementHandle } from 'playwright'
import type { UserEvent } from '../../../context'
import type { UserEventCommand } from './utils'
import { PlaywrightBrowserProvider } from '../providers/playwright'
import { WebdriverBrowserProvider } from '../providers/webdriver'
import type { UserEventCommand } from './utils'
export const selectOptions: UserEventCommand<UserEvent['selectOptions']> = async (
context,

View File

@ -1,7 +1,7 @@
import type { UserEvent } from '../../../context'
import type { UserEventCommand } from './utils'
import { PlaywrightBrowserProvider } from '../providers/playwright'
import { WebdriverBrowserProvider } from '../providers/webdriver'
import type { UserEventCommand } from './utils'
export const tab: UserEventCommand<UserEvent['tab']> = async (
context,

View File

@ -1,7 +1,7 @@
import type { UserEvent } from '../../../context'
import type { UserEventCommand } from './utils'
import { PlaywrightBrowserProvider } from '../providers/playwright'
import { WebdriverBrowserProvider } from '../providers/webdriver'
import type { UserEventCommand } from './utils'
import { keyboardImplementation } from './keyboard'
export const type: UserEventCommand<UserEvent['type']> = async (

View File

@ -1,7 +1,7 @@
import type { UserEventCommand } from './utils'
import { dirname, resolve } from 'pathe'
import { PlaywrightBrowserProvider } from '../providers/playwright'
import { WebdriverBrowserProvider } from '../providers/webdriver'
import type { UserEventCommand } from './utils'
export const upload: UserEventCommand<(element: string, files: Array<string | {
name: string

View File

@ -1,14 +1,14 @@
import type { WorkspaceProject } from 'vitest/node'
import type { Plugin } from 'vitest/config'
import { createViteLogger, createViteServer } from 'vitest/node'
import type { WorkspaceProject } from 'vitest/node'
import c from 'tinyrainbow'
import { createViteLogger, createViteServer } from 'vitest/node'
import { version } from '../../package.json'
import BrowserPlugin from './plugin'
import { setupBrowserRpc } from './rpc'
import { BrowserServer } from './server'
import BrowserPlugin from './plugin'
export type { BrowserServer } from './server'
export { createBrowserPool } from './pool'
export type { BrowserServer } from './server'
export async function createBrowserServer(
project: WorkspaceProject,

View File

@ -1,22 +1,22 @@
import { fileURLToPath } from 'node:url'
import { createRequire } from 'node:module'
import { lstatSync, readFileSync } from 'node:fs'
import type { Stats } from 'node:fs'
import type { WorkspaceProject } from 'vitest/node'
import type { BrowserServer } from './server'
import { lstatSync, readFileSync } from 'node:fs'
import { createRequire } from 'node:module'
import { fileURLToPath } from 'node:url'
import { dynamicImportPlugin } from '@vitest/mocker/node'
import { toArray } from '@vitest/utils'
import MagicString from 'magic-string'
import { basename, dirname, extname, resolve } from 'pathe'
import sirv from 'sirv'
import type { WorkspaceProject } from 'vitest/node'
import { coverageConfigDefaults, type Plugin } from 'vitest/config'
import { getFilePoolName, resolveApiServerConfig, resolveFsAllow, distDir as vitestDist } from 'vitest/node'
import { type Plugin, coverageConfigDefaults } from 'vitest/config'
import { toArray } from '@vitest/utils'
import { dynamicImportPlugin } from '@vitest/mocker/node'
import MagicString from 'magic-string'
import BrowserContext from './plugins/pluginContext'
import type { BrowserServer } from './server'
import { resolveOrchestrator } from './serverOrchestrator'
import { resolveTester } from './serverTester'
export type { BrowserCommand } from 'vitest/node'
export { defineBrowserCommand } from './commands/utils'
export type { BrowserCommand } from 'vitest/node'
export default (browserServer: BrowserServer, base = '/'): Plugin[] => {
const pkgRoot = resolve(fileURLToPath(import.meta.url), '../..')

View File

@ -1,11 +1,11 @@
import { fileURLToPath } from 'node:url'
import type { PluginContext } from 'rollup'
import type { Plugin } from 'vitest/config'
import type { BrowserProvider } from 'vitest/node'
import { dirname, resolve } from 'pathe'
import type { PluginContext } from 'rollup'
import { slash } from '@vitest/utils'
import builtinCommands from '../commands/index'
import type { BrowserServer } from '../server'
import { fileURLToPath } from 'node:url'
import { slash } from '@vitest/utils'
import { dirname, resolve } from 'pathe'
import builtinCommands from '../commands/index'
const VIRTUAL_ID_CONTEXT = '\0@vitest/browser/context'
const ID_CONTEXT = '@vitest/browser/context'

View File

@ -1,7 +1,7 @@
import * as nodeos from 'node:os'
import crypto from 'node:crypto'
import { relative } from 'pathe'
import type { BrowserProvider, ProcessPool, Vitest, WorkspaceProject, WorkspaceSpec } from 'vitest/node'
import crypto from 'node:crypto'
import * as nodeos from 'node:os'
import { relative } from 'pathe'
import { createDebugger } from 'vitest/node'
const debug = createDebugger('vitest:browser:pool')

View File

@ -1,6 +1,6 @@
import { PlaywrightBrowserProvider } from './playwright'
import { WebdriverBrowserProvider } from './webdriver'
import { PreviewBrowserProvider } from './preview'
import { WebdriverBrowserProvider } from './webdriver'
export const webdriverio = WebdriverBrowserProvider
export const playwright = PlaywrightBrowserProvider

View File

@ -1,15 +1,15 @@
import type { ErrorWithDiff } from 'vitest'
import type { BrowserCommandContext } from 'vitest/node'
import type { WebSocket } from 'ws'
import type { BrowserServer } from './server'
import type { WebSocketBrowserEvents, WebSocketBrowserHandlers } from './types'
import { existsSync, promises as fs } from 'node:fs'
import { dirname } from 'pathe'
import { ServerMockResolver } from '@vitest/mocker/node'
import { createBirpc } from 'birpc'
import { parse, stringify } from 'flatted'
import type { WebSocket } from 'ws'
import { WebSocketServer } from 'ws'
import type { BrowserCommandContext } from 'vitest/node'
import { dirname } from 'pathe'
import { createDebugger, isFileServingAllowed } from 'vitest/node'
import type { ErrorWithDiff } from 'vitest'
import { ServerMockResolver } from '@vitest/mocker/node'
import type { WebSocketBrowserEvents, WebSocketBrowserHandlers } from './types'
import type { BrowserServer } from './server'
import { WebSocketServer } from 'ws'
const debug = createDebugger('vitest:browser:api')

View File

@ -1,5 +1,5 @@
import { readFile } from 'node:fs/promises'
import { fileURLToPath } from 'node:url'
import type { ErrorWithDiff } from '@vitest/utils'
import type { SerializedConfig } from 'vitest'
import type {
BrowserProvider,
BrowserScript,
@ -8,14 +8,14 @@ import type {
Vite,
WorkspaceProject,
} from 'vitest/node'
import { join, resolve } from 'pathe'
import type { ErrorWithDiff } from '@vitest/utils'
import { readFile } from 'node:fs/promises'
import { fileURLToPath } from 'node:url'
import { slash } from '@vitest/utils'
import { type StackTraceParserOptions, parseErrorStacktrace, parseStacktrace } from '@vitest/utils/source-map'
import type { SerializedConfig } from 'vitest'
import { parseErrorStacktrace, parseStacktrace, type StackTraceParserOptions } from '@vitest/utils/source-map'
import { join, resolve } from 'pathe'
import { BrowserServerCDPHandler } from './cdp'
import { BrowserServerState } from './state'
import { getBrowserProvider } from './utils'
import { BrowserServerCDPHandler } from './cdp'
export class BrowserServer implements IBrowserServer {
public faviconUrl: string

View File

@ -1,8 +1,8 @@
import type { IncomingMessage, ServerResponse } from 'node:http'
import type { BrowserServer } from './server'
import crypto from 'node:crypto'
import { stringify } from 'flatted'
import { replacer } from './utils'
import type { BrowserServer } from './server'
export async function resolveTester(
server: BrowserServer,

View File

@ -1,7 +1,7 @@
import { createDefer } from '@vitest/utils'
import type { BrowserServerStateContext, BrowserServerState as IBrowserServerState } from 'vitest/node'
import type { WebSocketBrowserRPC } from './types'
import type { BrowserServerCDPHandler } from './cdp'
import type { WebSocketBrowserRPC } from './types'
import { createDefer } from '@vitest/utils'
export class BrowserServerState implements IBrowserServerState {
public readonly orchestrators = new Map<string, WebSocketBrowserRPC>()

View File

@ -1,10 +1,10 @@
import { builtinModules, createRequire } from 'node:module'
import esbuild from 'rollup-plugin-esbuild'
import dts from 'rollup-plugin-dts'
import commonjs from '@rollup/plugin-commonjs'
import json from '@rollup/plugin-json'
import nodeResolve from '@rollup/plugin-node-resolve'
import { join } from 'pathe'
import dts from 'rollup-plugin-dts'
import esbuild from 'rollup-plugin-esbuild'
const require = createRequire(import.meta.url)
const pkg = require('./package.json')

View File

@ -1,5 +1,5 @@
import { COVERAGE_STORE_KEY } from './constants'
import type { IstanbulCoverageProvider } from './provider'
import { COVERAGE_STORE_KEY } from './constants'
export async function getProvider(): Promise<IstanbulCoverageProvider> {
// to not bundle the provider

View File

@ -1,16 +1,16 @@
import { promises as fs } from 'node:fs'
import { resolve } from 'pathe'
import type { CoverageProvider, ReportContext, ResolvedCoverageOptions, Vitest } from 'vitest/node'
import { BaseCoverageProvider } from 'vitest/coverage'
import c from 'tinyrainbow'
import { parseModule } from 'magicast'
import { promises as fs } from 'node:fs'
import createDebug from 'debug'
import TestExclude from 'test-exclude'
import libReport from 'istanbul-lib-report'
import reports from 'istanbul-reports'
import libCoverage, { type CoverageMap } from 'istanbul-lib-coverage'
import { createInstrumenter, type Instrumenter } from 'istanbul-lib-instrument'
import libReport from 'istanbul-lib-report'
import libSourceMaps from 'istanbul-lib-source-maps'
import { type Instrumenter, createInstrumenter } from 'istanbul-lib-instrument'
import reports from 'istanbul-reports'
import { parseModule } from 'magicast'
import { resolve } from 'pathe'
import TestExclude from 'test-exclude'
import c from 'tinyrainbow'
import { BaseCoverageProvider } from 'vitest/coverage'
// @ts-expect-error missing types
import { defaults as istanbulDefaults } from '@istanbuljs/schema'

View File

@ -1,10 +1,10 @@
import { builtinModules, createRequire } from 'node:module'
import esbuild from 'rollup-plugin-esbuild'
import dts from 'rollup-plugin-dts'
import commonjs from '@rollup/plugin-commonjs'
import json from '@rollup/plugin-json'
import nodeResolve from '@rollup/plugin-node-resolve'
import { join } from 'pathe'
import dts from 'rollup-plugin-dts'
import esbuild from 'rollup-plugin-esbuild'
const require = createRequire(import.meta.url)
const pkg = require('./package.json')

View File

@ -1,5 +1,5 @@
import { cdp } from '@vitest/browser/context'
import type { V8CoverageProvider } from './provider'
import { cdp } from '@vitest/browser/context'
import { loadProvider } from './load-provider'
const session = cdp()

View File

@ -1,6 +1,6 @@
import type { V8CoverageProvider } from './provider'
import inspector, { type Profiler } from 'node:inspector'
import { provider } from 'std-env'
import type { V8CoverageProvider } from './provider'
import { loadProvider } from './load-provider'
const session = new inspector.Session()

View File

@ -1,27 +1,27 @@
import type { CoverageMap } from 'istanbul-lib-coverage'
import type { Profiler } from 'node:inspector'
import { fileURLToPath, pathToFileURL } from 'node:url'
import type { EncodedSourceMap, FetchResult } from 'vite-node'
import type { AfterSuiteRunMeta } from 'vitest'
import type { CoverageProvider, ReportContext, ResolvedCoverageOptions, Vitest, WorkspaceProject } from 'vitest/node'
import { promises as fs } from 'node:fs'
import v8ToIstanbul from 'v8-to-istanbul'
import { fileURLToPath, pathToFileURL } from 'node:url'
import remapping from '@ampproject/remapping'
import { mergeProcessCovs } from '@bcoe/v8-coverage'
import createDebug from 'debug'
import libCoverage from 'istanbul-lib-coverage'
import libReport from 'istanbul-lib-report'
import libSourceMaps from 'istanbul-lib-source-maps'
import reports from 'istanbul-reports'
import type { CoverageMap } from 'istanbul-lib-coverage'
import MagicString from 'magic-string'
import { parseModule } from 'magicast'
import { normalize, resolve } from 'pathe'
import { provider } from 'std-env'
import c from 'tinyrainbow'
import createDebug from 'debug'
import MagicString from 'magic-string'
import TestExclude from 'test-exclude'
import remapping from '@ampproject/remapping'
import { BaseCoverageProvider } from 'vitest/coverage'
import c from 'tinyrainbow'
import v8ToIstanbul from 'v8-to-istanbul'
import { cleanUrl } from 'vite-node/utils'
import type { AfterSuiteRunMeta } from 'vitest'
import type { CoverageProvider, ReportContext, ResolvedCoverageOptions, Vitest, WorkspaceProject } from 'vitest/node'
import type { EncodedSourceMap, FetchResult } from 'vite-node'
import { parseModule } from 'magicast'
import { BaseCoverageProvider } from 'vitest/coverage'
import { version } from '../package.json' with { type: 'json' }
type TransformResults = Map<string, FetchResult>

View File

@ -5,12 +5,12 @@ Jest's expect matchers as a Chai plugin.
## Usage
```js
import * as chai from 'chai'
import {
JestAsymmetricMatchers,
JestChaiExpect,
JestExtend,
} from '@vitest/expect'
import * as chai from 'chai'
// allows using expect.extend instead of chai.use to extend plugins
chai.use(JestExtend)

View File

@ -1,8 +1,8 @@
import { builtinModules, createRequire } from 'node:module'
import esbuild from 'rollup-plugin-esbuild'
import dts from 'rollup-plugin-dts'
import { defineConfig } from 'rollup'
import copy from 'rollup-plugin-copy'
import dts from 'rollup-plugin-dts'
import esbuild from 'rollup-plugin-esbuild'
const require = createRequire(import.meta.url)
const pkg = require('./package.json')

View File

@ -1,8 +1,8 @@
export * from './jest-asymmetric-matchers'
export * from './jest-utils'
export * from './constants'
export * from './types'
export { getState, setState } from './state'
export * from './jest-asymmetric-matchers'
export { JestChaiExpect } from './jest-expect'
export { addCustomEqualityTesters } from './jest-matcher-utils'
export { JestExtend } from './jest-extend'
export { addCustomEqualityTesters } from './jest-matcher-utils'
export * from './jest-utils'
export { getState, setState } from './state'
export * from './types'

View File

@ -1,13 +1,11 @@
import type { ChaiPlugin, MatcherState } from './types'
import { GLOBAL_EXPECT } from './constants'
import { getState } from './state'
import {
diff,
getCustomEqualityTesters,
getMatcherUtils,
stringify,
} from './jest-matcher-utils'
import {
equals,
isA,
@ -16,6 +14,8 @@ import {
subsetEquality,
} from './jest-utils'
import { getState } from './state'
export interface AsymmetricMatcherInterface {
asymmetricMatch: (other: unknown) => boolean
toString: () => string

View File

@ -1,10 +1,17 @@
import type { Test } from '@vitest/runner'
import type { MockInstance, MockResult, MockSettledResult } from '@vitest/spy'
import type { Constructable } from '@vitest/utils'
import type { AsymmetricMatcher } from './jest-asymmetric-matchers'
import type { Assertion, ChaiPlugin } from './types'
import { isMockFunction } from '@vitest/spy'
import { assertTypes } from '@vitest/utils'
import c from 'tinyrainbow'
import type { Constructable } from '@vitest/utils'
import type { MockInstance, MockResult, MockSettledResult } from '@vitest/spy'
import { isMockFunction } from '@vitest/spy'
import type { Test } from '@vitest/runner'
import type { Assertion, ChaiPlugin } from './types'
import { JEST_MATCHERS_OBJECT } from './constants'
import {
diff,
getCustomEqualityTesters,
stringify,
} from './jest-matcher-utils'
import {
arrayBufferEquality,
generateToBeMessage,
@ -15,13 +22,6 @@ import {
subsetEquality,
typeEquality,
} from './jest-utils'
import type { AsymmetricMatcher } from './jest-asymmetric-matchers'
import {
diff,
getCustomEqualityTesters,
stringify,
} from './jest-matcher-utils'
import { JEST_MATCHERS_OBJECT } from './constants'
import { recordAsyncExpect, wrapAssertion } from './utils'
// polyfill globals because expect can be used in node environment

View File

@ -1,15 +1,13 @@
import { use, util } from 'chai'
import type {
ChaiPlugin,
ExpectStatic,
MatcherState,
MatchersObject,
MatcherState,
SyncExpectationResult,
} from './types'
import { use, util } from 'chai'
import { ASYMMETRIC_MATCHERS_OBJECT, JEST_MATCHERS_OBJECT } from './constants'
import { AsymmetricMatcher } from './jest-asymmetric-matchers'
import { getState } from './state'
import {
diff,
getCustomEqualityTesters,
@ -18,6 +16,8 @@ import {
} from './jest-matcher-utils'
import { equals, iterableEquality, subsetEquality } from './jest-utils'
import { getState } from './state'
import { wrapAssertion } from './utils'
function getMatcherState(

View File

@ -1,7 +1,7 @@
import { getType, stringify } from '@vitest/utils'
import c from 'tinyrainbow'
import { diff, printDiffOrStringify } from '@vitest/utils/diff'
import type { MatcherHintOptions, Tester } from './types'
import { getType, stringify } from '@vitest/utils'
import { diff, printDiffOrStringify } from '@vitest/utils/diff'
import c from 'tinyrainbow'
import { JEST_MATCHERS_OBJECT } from './constants'
export { diff } from '@vitest/utils/diff'

View File

@ -22,8 +22,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
import { isObject } from '@vitest/utils'
import type { Tester, TesterContext } from './types'
import { isObject } from '@vitest/utils'
// Extracted out of jasmine 2.5.2
export function equals(

View File

@ -6,8 +6,8 @@
*
*/
import type { Formatter } from 'tinyrainbow'
import type { Constructable } from '@vitest/utils'
import type { Formatter } from 'tinyrainbow'
import type { diff, getMatcherUtils, stringify } from './jest-matcher-utils'
export type ChaiPlugin = Chai.ChaiPlugin

View File

@ -1,6 +1,6 @@
import { processError } from '@vitest/utils/error'
import type { Test } from '@vitest/runner/types'
import type { Assertion } from './types'
import { processError } from '@vitest/utils/error'
export function recordAsyncExpect(
test: any,

View File

@ -1,10 +1,10 @@
import { builtinModules, createRequire } from 'node:module'
import { defineConfig } from 'rollup'
import esbuild from 'rollup-plugin-esbuild'
import dts from 'rollup-plugin-dts'
import resolve from '@rollup/plugin-node-resolve'
import json from '@rollup/plugin-json'
import commonjs from '@rollup/plugin-commonjs'
import json from '@rollup/plugin-json'
import resolve from '@rollup/plugin-node-resolve'
import { defineConfig } from 'rollup'
import dts from 'rollup-plugin-dts'
import esbuild from 'rollup-plugin-esbuild'
const require = createRequire(import.meta.url)
const pkg = require('./package.json')

View File

@ -1,8 +1,8 @@
import type { MaybeMockedDeep } from '@vitest/spy'
import { createSimpleStackTrace } from '@vitest/utils'
import { parseSingleStack } from '@vitest/utils/source-map'
import type { ModuleMockFactoryWithHelper, ModuleMockOptions } from '../types'
import type { ModuleMocker } from './mocker'
import { createSimpleStackTrace } from '@vitest/utils'
import { parseSingleStack } from '@vitest/utils/source-map'
export interface CompilerHintsOptions {
/**

View File

@ -1,13 +1,13 @@
export { createCompilerHints } from './hints'
export type { CompilerHintsOptions, ModuleMockerCompilerHints } from './hints'
export type { ModuleMockerInterceptor } from './interceptor'
export { ModuleMocker } from './mocker'
export { ModuleMockerMSWInterceptor, type ModuleMockerMSWInterceptorOptions } from './interceptor-msw'
export { ModuleMockerServerInterceptor } from './interceptor-native'
export { ModuleMockerServerInterceptor } from './interceptor-native'
export { ModuleMocker } from './mocker'
export type {
ModuleMockerRPC,
ModuleMockerConfig,
ModuleMockerRPC,
ResolveIdResult,
ResolveMockResul,
} from './mocker'
export { createCompilerHints } from './hints'
export type { CompilerHintsOptions, ModuleMockerCompilerHints } from './hints'

View File

@ -1,9 +1,9 @@
import type { SetupWorker, StartOptions } from 'msw/browser'
import type { HttpHandler } from 'msw'
import type { SetupWorker, StartOptions } from 'msw/browser'
import type { ManualMockedModule, MockedModule } from '../registry'
import type { ModuleMockerInterceptor } from './interceptor'
import { MockerRegistry } from '../registry'
import { cleanUrl } from '../utils'
import type { ModuleMockerInterceptor } from './interceptor'
export interface ModuleMockerMSWInterceptorOptions {
/**
@ -127,11 +127,10 @@ export class ModuleMockerMSWInterceptor implements ModuleMockerInterceptor {
}),
)
return worker.start(this.options.mswOptions)
}).finally(() => {
this.started = true
this.startPromise = undefined
})
.finally(() => {
this.started = true
this.startPromise = undefined
})
await this.startPromise
}
}

View File

@ -1,9 +1,9 @@
import { extname, join } from 'pathe'
import type { MockedModule, MockedModuleType } from '../registry'
import { AutomockedModule, MockerRegistry, RedirectedModule } from '../registry'
import type { ModuleMockOptions } from '../types'
import { mockObject } from '../automocker'
import type { ModuleMockerInterceptor } from './interceptor'
import { extname, join } from 'pathe'
import { mockObject } from '../automocker'
import { AutomockedModule, MockerRegistry, RedirectedModule } from '../registry'
const { now } = Date

View File

@ -1,9 +1,9 @@
import { spyOn } from '@vitest/spy'
import type { ModuleMockerCompilerHints } from './hints'
import { createCompilerHints } from './hints'
import { hot, rpc } from './utils'
import type { ModuleMockerInterceptor } from './index'
import { spyOn } from '@vitest/spy'
import { createCompilerHints } from './hints'
import { ModuleMocker } from './index'
import { hot, rpc } from './utils'
declare const __VITEST_GLOBAL_THIS_ACCESSOR__: string
declare const __VITEST_MOCKER_ROOT__: string

View File

@ -1,21 +1,21 @@
export { mockObject } from './automocker'
export type { GlobalConstructors, MockObjectOptions } from './automocker'
export {
MockerRegistry,
ManualMockedModule,
RedirectedModule,
AutomockedModule,
AutospiedModule,
ManualMockedModule,
MockerRegistry,
RedirectedModule,
} from './registry'
export { mockObject } from './automocker'
export type { GlobalConstructors, MockObjectOptions } from './automocker'
export type {
MockedModule,
MockedModuleType,
MockedModuleSerialized,
AutomockedModuleSerialized,
AutospiedModuleSerialized,
RedirectedModuleSerialized,
ManualMockedModuleSerialized,
MockedModule,
MockedModuleSerialized,
MockedModuleType,
RedirectedModuleSerialized,
} from './registry'
export type {

View File

@ -1,15 +1,15 @@
import MagicString from 'magic-string'
import type { Plugin } from 'vite'
import MagicString from 'magic-string'
import { cleanUrl } from '../utils'
import {
type Declaration,
type ExportDefaultDeclaration,
type ExportNamedDeclaration,
type Expression,
getArbitraryModuleIdentifier,
type Pattern,
type Positioned,
type Program,
getArbitraryModuleIdentifier,
} from './esmWalker'
export interface AutomockPluginOptions {

View File

@ -1,7 +1,7 @@
import type { SourceMap } from 'magic-string'
import MagicString from 'magic-string'
import type { Plugin, Rollup } from 'vite'
import type { Expression, Positioned } from './esmWalker'
import MagicString from 'magic-string'
import { esmWalker } from './esmWalker'
const regexDynamicImport = /import\s*\(/

View File

@ -1,4 +1,5 @@
import type {
Node as _Node,
CallExpression,
Function as FunctionNode,
Identifier,
@ -7,10 +8,9 @@ import type {
Pattern,
Property,
VariableDeclaration,
Node as _Node,
} from 'estree'
import { walk as eswalk } from 'estree-walker'
import type { Rollup } from 'vite'
import { walk as eswalk } from 'estree-walker'
export type * from 'estree'

View File

@ -1,5 +1,3 @@
import type { SourceMap } from 'magic-string'
import MagicString from 'magic-string'
import type {
AwaitExpression,
CallExpression,
@ -11,10 +9,12 @@ import type {
ImportExpression,
VariableDeclaration,
} from 'estree'
import { findNodeAround } from 'acorn-walk'
import type { SourceMap } from 'magic-string'
import type { Plugin, Rollup } from 'vite'
import { createFilter } from 'vite'
import type { Node, Positioned } from './esmWalker'
import { findNodeAround } from 'acorn-walk'
import MagicString from 'magic-string'
import { createFilter } from 'vite'
import { esmWalker, getArbitraryModuleIdentifier } from './esmWalker'
interface HoistMocksOptions {

View File

@ -1,16 +1,16 @@
export { automockModule, automockPlugin } from './automockPlugin'
export { findMockRedirect } from './redirect'
export { hoistMocksPlugin, hoistMocks } from './hoistMocksPlugin'
export { ServerMockResolver } from './resolver'
export type { AutomockPluginOptions } from './automockPlugin'
export { dynamicImportPlugin } from './dynamicImportPlugin'
export { hoistMocks, hoistMocksPlugin } from './hoistMocksPlugin'
export type { HoistMocksPluginOptions, HoistMocksResult } from './hoistMocksPlugin'
export { interceptorPlugin } from './interceptorPlugin'
export { mockerPlugin } from './mockerPlugin'
export type { InterceptorPluginOptions } from './interceptorPlugin'
export { mockerPlugin } from './mockerPlugin'
export { findMockRedirect } from './redirect'
export { ServerMockResolver } from './resolver'
export type {
ServerMockResolution,
ServerIdResolution,
ServerMockResolution,
ServerResolverOptions,
} from './resolver'
export type { AutomockPluginOptions } from './automockPlugin'
export type { HoistMocksPluginOptions, HoistMocksResult } from './hoistMocksPlugin'
export type { InterceptorPluginOptions } from './interceptorPlugin'

View File

@ -1,7 +1,7 @@
import { join } from 'node:path/posix'
import { readFile } from 'node:fs/promises'
import type { Plugin } from 'vite'
import type { MockedModuleSerialized } from '../registry'
import { readFile } from 'node:fs/promises'
import { join } from 'node:path/posix'
import { ManualMockedModule, MockerRegistry } from '../registry'
import { cleanUrl } from '../utils'
import { automockModule } from './automockPlugin'

View File

@ -1,13 +1,13 @@
import { fileURLToPath } from 'node:url'
import { readFile } from 'node:fs/promises'
import type { Plugin, ViteDevServer } from 'vite'
import { readFile } from 'node:fs/promises'
import { fileURLToPath } from 'node:url'
import { resolve } from 'pathe'
import { type AutomockPluginOptions, automockPlugin } from './automockPlugin'
import { type HoistMocksPluginOptions, hoistMocksPlugin } from './hoistMocksPlugin'
import { automockPlugin, type AutomockPluginOptions } from './automockPlugin'
import { dynamicImportPlugin } from './dynamicImportPlugin'
import { ServerMockResolver } from './resolver'
import { hoistMocksPlugin, type HoistMocksPluginOptions } from './hoistMocksPlugin'
import { interceptorPlugin } from './interceptorPlugin'
import { ServerMockResolver } from './resolver'
interface MockerPluginOptions extends AutomockPluginOptions {
hoistMocks?: HoistMocksPluginOptions

View File

@ -1,7 +1,7 @@
import { existsSync, readFileSync } from 'node:fs'
import { isAbsolute, join, resolve } from 'pathe'
import type { PartialResolvedId } from 'rollup'
import type { ResolvedConfig as ViteConfig, ViteDevServer } from 'vite'
import { existsSync, readFileSync } from 'node:fs'
import { isAbsolute, join, resolve } from 'pathe'
import { cleanUrl } from '../utils'
import { findMockRedirect } from './redirect'

View File

@ -1,10 +1,10 @@
import { builtinModules, createRequire } from 'node:module'
import { defineConfig } from 'rollup'
import esbuild from 'rollup-plugin-esbuild'
import dts from 'rollup-plugin-dts'
import resolve from '@rollup/plugin-node-resolve'
import json from '@rollup/plugin-json'
import commonjs from '@rollup/plugin-commonjs'
import json from '@rollup/plugin-json'
import resolve from '@rollup/plugin-node-resolve'
import { defineConfig } from 'rollup'
import dts from 'rollup-plugin-dts'
import esbuild from 'rollup-plugin-esbuild'
const require = createRequire(import.meta.url)
const pkg = require('./package.json')

View File

@ -5,6 +5,17 @@
* LICENSE file in the root directory of this source tree.
*/
import type {
Colors,
Config,
NewPlugin,
Options,
OptionsReceived,
Plugin,
Plugins,
Refs,
Theme,
} from './types'
import styles from 'tinyrainbow'
import {
printIteratorEntries,
@ -18,26 +29,15 @@ import DOMElement from './plugins/DOMElement'
import Immutable from './plugins/Immutable'
import ReactElement from './plugins/ReactElement'
import ReactTestComponent from './plugins/ReactTestComponent'
import type {
Colors,
Config,
NewPlugin,
Options,
OptionsReceived,
Plugin,
Plugins,
Refs,
Theme,
} from './types'
export type {
Colors,
CompareKeys,
Config,
NewPlugin,
OldPlugin,
Options,
OptionsReceived,
OldPlugin,
NewPlugin,
Plugin,
Plugins,
PrettyFormatOptions,

View File

@ -5,8 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/
import { printListItems, printObjectProperties } from '../collections'
import type { Config, NewPlugin, Printer, Refs } from '../types'
import { printListItems, printObjectProperties } from '../collections'
const asymmetricMatcher
= typeof Symbol === 'function' && Symbol.for

View File

@ -5,8 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/
import { printListItems, printObjectProperties } from '../collections'
import type { Config, NewPlugin, Printer, Refs } from '../types'
import { printListItems, printObjectProperties } from '../collections'
const SPACE = ' '

View File

@ -5,8 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/
import { printIteratorEntries, printIteratorValues } from '../collections'
import type { Config, NewPlugin, Printer, Refs } from '../types'
import { printIteratorEntries, printIteratorValues } from '../collections'
// SENTINEL constants are from https://github.com/facebook/immutable-js
const IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@'

View File

@ -5,8 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/
import * as ReactIs from 'react-is'
import type { Config, NewPlugin, Printer, Refs } from '../types'
import * as ReactIs from 'react-is'
import {
printChildren,
printElement,

View File

@ -1,8 +1,8 @@
import { builtinModules, createRequire } from 'node:module'
import esbuild from 'rollup-plugin-esbuild'
import json from '@rollup/plugin-json'
import dts from 'rollup-plugin-dts'
import { defineConfig } from 'rollup'
import dts from 'rollup-plugin-dts'
import esbuild from 'rollup-plugin-esbuild'
const require = createRequire(import.meta.url)
const pkg = require('./package.json')

View File

@ -1,21 +1,21 @@
import { processError } from '@vitest/utils/error'
import { toArray } from '@vitest/utils'
import type { File, SuiteHooks } from './types/tasks'
import type { VitestRunner } from './types/runner'
import type { File, SuiteHooks } from './types/tasks'
import { toArray } from '@vitest/utils'
import { processError } from '@vitest/utils/error'
import { collectorContext } from './context'
import { getHooks, setHooks } from './map'
import { runSetupFiles } from './setup'
import {
clearCollectorContext,
createSuiteHooks,
getDefaultSuite,
} from './suite'
import {
calculateSuiteHash,
createFileTask,
interpretTaskModes,
someTasksAreOnly,
} from './utils/collect'
import {
clearCollectorContext,
createSuiteHooks,
getDefaultSuite,
} from './suite'
import { getHooks, setHooks } from './map'
import { collectorContext } from './context'
import { runSetupFiles } from './setup'
const now = globalThis.performance ? globalThis.performance.now.bind(globalThis.performance) : Date.now

View File

@ -1,5 +1,5 @@
import type { Awaitable } from '@vitest/utils'
import { getSafeTimers } from '@vitest/utils'
import type { VitestRunner } from './types/runner'
import type {
Custom,
ExtendedContext,
@ -8,7 +8,7 @@ import type {
TaskContext,
Test,
} from './types/tasks'
import type { VitestRunner } from './types/runner'
import { getSafeTimers } from '@vitest/utils'
import { PendingError } from './errors'
export const collectorContext: RuntimeContext = {

View File

@ -1,6 +1,6 @@
import type { FixtureOptions, TestContext } from './types/tasks'
import { createDefer, isObject } from '@vitest/utils'
import { getFixture } from './map'
import type { FixtureOptions, TestContext } from './types/tasks'
export interface FixtureItem extends FixtureOptions {
prop: string

View File

@ -1,4 +1,3 @@
import { assertTypes } from '@vitest/utils'
import type {
AfterAllListener,
AfterEachListener,
@ -9,10 +8,11 @@ import type {
TaskHook,
TaskPopulated,
} from './types/tasks'
import { getCurrentSuite, getRunner } from './suite'
import { getCurrentTest } from './test-state'
import { assertTypes } from '@vitest/utils'
import { withTimeout } from './context'
import { withFixtures } from './fixture'
import { getCurrentSuite, getRunner } from './suite'
import { getCurrentTest } from './test-state'
function getDefaultHookTimeout() {
return getRunner().config.hookTimeout

View File

@ -1,22 +1,22 @@
export { startTests, updateTask, collectTests } from './run'
export {
test,
it,
describe,
suite,
getCurrentSuite,
createTaskCollector,
} from './suite'
export {
beforeAll,
beforeEach,
afterAll,
afterEach,
beforeAll,
beforeEach,
onTestFailed,
onTestFinished,
} from './hooks'
export { setFn, getFn, getHooks, setHooks } from './map'
export { getFn, getHooks, setFn, setHooks } from './map'
export { collectTests, startTests, updateTask } from './run'
export {
createTaskCollector,
describe,
getCurrentSuite,
it,
suite,
test,
} from './suite'
export { getCurrentTest } from './test-state'
export { processError } from '@vitest/utils/error'
export type * from './types'
export { processError } from '@vitest/utils/error'

Some files were not shown because too many files have changed in this diff Show More