mirror of
https://github.com/vitest-dev/vitest.git
synced 2025-12-08 18:26:03 +00:00
feat: support rolldown-vite (#7509)
Co-authored-by: Hiroshi Ogawa <hi.ogawa.zz@gmail.com>
This commit is contained in:
parent
6db9f5207c
commit
c8d6264bf4
36
.github/workflows/ci.yml
vendored
36
.github/workflows/ci.yml
vendored
@ -157,3 +157,39 @@ jobs:
|
||||
|
||||
- name: Test Browser (webdriverio)
|
||||
run: pnpm run test:browser:webdriverio
|
||||
|
||||
test-rolldown:
|
||||
needs: changed
|
||||
# macos-latest is the fastes one
|
||||
name: 'Rolldown&Test: node-20, macos-latest'
|
||||
if: needs.changed.outputs.should_skip != 'true'
|
||||
runs-on: macos-latest
|
||||
|
||||
timeout-minutes: 30
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: ./.github/actions/setup-and-cache
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
- uses: browser-actions/setup-chrome@c785b87e244131f27c9f19c1a33e2ead956ab7ce # v1.7.3
|
||||
|
||||
- name: Install
|
||||
run: pnpm add vite@npm:rolldown-vite && git add . && git commit -m "ci" && pnpm i --prefer-offline --no-frozen-lockfile
|
||||
|
||||
- name: Install Playwright Dependencies
|
||||
run: pnpm exec playwright install --with-deps --only-shell
|
||||
|
||||
- name: Build
|
||||
run: pnpm run build
|
||||
|
||||
- name: Test
|
||||
run: pnpm run test:ci
|
||||
|
||||
- name: Test Examples
|
||||
run: pnpm run test:examples
|
||||
|
||||
- name: Test Browser (playwright)
|
||||
run: pnpm run test:browser:playwright
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
"build": "pnpm -r --filter @vitest/ui --filter='./packages/**' run build",
|
||||
"dev": "NODE_OPTIONS=\"--max-old-space-size=8192\" pnpm -r --parallel --filter='./packages/**' run dev",
|
||||
"docs": "pnpm -C docs run dev",
|
||||
"docs:build": "pnpm -C docs run build",
|
||||
"docs:build": "ROLLDOWN_OPTIONS_VALIDATION=loose pnpm -C docs run build",
|
||||
"docs:serve": "pnpm -C docs run serve",
|
||||
"docs:https": "pnpm -C docs run preview-https",
|
||||
"docs:https-no-prefetch": "pnpm -C docs run preview-https-no-prefetch",
|
||||
@ -96,6 +96,7 @@
|
||||
"esbuild",
|
||||
"geckodriver",
|
||||
"msw",
|
||||
"rolldown",
|
||||
"sharp",
|
||||
"svelte-preprocess",
|
||||
"vue-demi"
|
||||
|
||||
@ -366,7 +366,7 @@ function createSuiteCollector(
|
||||
|
||||
if (runner.config.includeTaskLocation) {
|
||||
const error = stackTraceError.stack!
|
||||
const stack = findTestFileStackTrace(error, task.each ?? false)
|
||||
const stack = findTestFileStackTrace(error)
|
||||
if (stack) {
|
||||
task.location = stack
|
||||
}
|
||||
@ -460,7 +460,7 @@ function createSuiteCollector(
|
||||
Error.stackTraceLimit = 15
|
||||
const error = new Error('stacktrace').stack!
|
||||
Error.stackTraceLimit = limit
|
||||
const stack = findTestFileStackTrace(error, suite.each ?? false)
|
||||
const stack = findTestFileStackTrace(error)
|
||||
if (stack) {
|
||||
suite.location = stack
|
||||
}
|
||||
@ -890,21 +890,16 @@ function formatTemplateString(cases: any[], args: any[]): any[] {
|
||||
return res
|
||||
}
|
||||
|
||||
function findTestFileStackTrace(error: string, each: boolean) {
|
||||
function findTestFileStackTrace(error: string) {
|
||||
const testFilePath = getTestFilepath()
|
||||
// first line is the error message
|
||||
const lines = error.split('\n').slice(1)
|
||||
for (const line of lines) {
|
||||
const stack = parseSingleStack(line)
|
||||
if (stack && stack.file === getTestFilepath()) {
|
||||
if (stack && stack.file === testFilePath) {
|
||||
return {
|
||||
line: stack.line,
|
||||
/**
|
||||
* test.each([1, 2])('name')
|
||||
* ^ leads here, but should
|
||||
* ^ lead here
|
||||
* in source maps it's the same boundary, so it just points to the start of it
|
||||
*/
|
||||
column: each ? stack.column + 1 : stack.column,
|
||||
column: stack.column,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,7 +26,7 @@ export function NormalizeURLPlugin(): Plugin {
|
||||
const assetImportMetaUrlRE
|
||||
// vite injects new URL(path, import.meta.url) in the code
|
||||
// rolldown-vite injects new URL(path, '' + import.meta.url) in the code
|
||||
= /\bnew\s+URL\s*\(\s*(?:'[^']+'|"[^"]+"|`[^`]+`)\s*,\s*(?:'' \+ )?import\.meta\.url\s*(?:,\s*)?\)/g
|
||||
= /\bnew\s+URL\s*\(\s*(?:'[^']+'|"[^"]+"|`[^`]+`)\s*,\s*(?:'' \+ )?import\.meta\.url\s*(?:,\s*)?\)/g
|
||||
|
||||
let updatedCode = code
|
||||
let match: RegExpExecArray | null
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import type { ModuleDiagnostic as _FileDiagnostic } from '../node/reporters/reported-tasks'
|
||||
import { createServer as _createServer } from 'vite'
|
||||
import * as vite from 'vite'
|
||||
import { Vitest } from '../node/core'
|
||||
import { TestModule as _TestFile } from '../node/reporters/reported-tasks'
|
||||
|
||||
@ -81,8 +81,8 @@ export type {
|
||||
ResolvedBrowserOptions,
|
||||
} from '../node/types/browser'
|
||||
/** @deprecated use `createViteServer` instead */
|
||||
export const createServer: typeof _createServer = _createServer
|
||||
export const createViteServer: typeof _createServer = _createServer
|
||||
export const createServer: typeof vite.createServer = vite.createServer
|
||||
export const createViteServer: typeof vite.createServer = vite.createServer
|
||||
export type {
|
||||
ApiConfig,
|
||||
BuiltinEnvironment,
|
||||
@ -175,4 +175,7 @@ export {
|
||||
version as viteVersion,
|
||||
} from 'vite'
|
||||
|
||||
// rolldownVersion is exported only by rolldown-vite
|
||||
export const rolldownVersion: string | undefined = (vite as any).rolldownVersion
|
||||
|
||||
export type * as Vite from 'vite'
|
||||
|
||||
1282
pnpm-lock.yaml
generated
1282
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@ -14,6 +14,7 @@ export default defineConfig({
|
||||
screenshotFailures: false,
|
||||
headless: true,
|
||||
instances,
|
||||
headless: true,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
"test-mocking": "vitest --root ./fixtures/mocking",
|
||||
"test-failing": "vitest --root ./fixtures/failing",
|
||||
"test-timeout": "vitest --root ./fixtures/timeout",
|
||||
"test-timeout-hooks": "vitest --root ./fixtures/timeout-hooks",
|
||||
"test-mocking-watch": "vitest --root ./fixtures/mocking-watch",
|
||||
"test-locators": "vitest --root ./fixtures/locators",
|
||||
"test-locators-custom": "vitest --root ./fixtures/locators-custom",
|
||||
|
||||
@ -2,6 +2,7 @@ import type { Vitest } from 'vitest/node'
|
||||
import type { JsonTestResults } from 'vitest/reporters'
|
||||
import { readFile } from 'node:fs/promises'
|
||||
import { beforeAll, describe, expect, onTestFailed, test } from 'vitest'
|
||||
import { rolldownVersion } from 'vitest/node'
|
||||
import { instances, provider, runBrowserTests } from './utils'
|
||||
|
||||
function noop() {}
|
||||
@ -261,7 +262,120 @@ test.runIf(provider === 'playwright')('timeout hooks', async () => {
|
||||
].join('\n')
|
||||
}).sort().join('\n\n')
|
||||
|
||||
expect(snapshot).toMatchInlineSnapshot(`
|
||||
// rolldown has better source maps
|
||||
if (rolldownVersion) {
|
||||
expect(snapshot).toMatchInlineSnapshot(`
|
||||
" FAIL |chromium| hooks-timeout.test.ts > timeouts are failing correctly > afterAll
|
||||
TimeoutError: locator.click: Timeout <ms> exceeded.
|
||||
❯ hooks-timeout.test.ts:44:45
|
||||
|
||||
FAIL |chromium| hooks-timeout.test.ts > timeouts are failing correctly > afterEach > skipped
|
||||
TimeoutError: locator.click: Timeout <ms> exceeded.
|
||||
❯ hooks-timeout.test.ts:26:45
|
||||
|
||||
FAIL |chromium| hooks-timeout.test.ts > timeouts are failing correctly > beforeAll
|
||||
TimeoutError: locator.click: Timeout <ms> exceeded.
|
||||
❯ hooks-timeout.test.ts:35:45
|
||||
|
||||
FAIL |chromium| hooks-timeout.test.ts > timeouts are failing correctly > beforeEach > skipped
|
||||
TimeoutError: locator.click: Timeout <ms> exceeded.
|
||||
❯ hooks-timeout.test.ts:17:45
|
||||
|
||||
FAIL |chromium| hooks-timeout.test.ts > timeouts are failing correctly > click on non-existing element fails
|
||||
TimeoutError: locator.click: Timeout <ms> exceeded.
|
||||
❯ hooks-timeout.test.ts:7:33
|
||||
|
||||
FAIL |chromium| hooks-timeout.test.ts > timeouts are failing correctly > onTestFailed > fails
|
||||
TimeoutError: locator.click: Timeout <ms> exceeded.
|
||||
❯ hooks-timeout.test.ts:70:47
|
||||
|
||||
FAIL |chromium| hooks-timeout.test.ts > timeouts are failing correctly > onTestFailed > fails global
|
||||
TimeoutError: locator.click: Timeout <ms> exceeded.
|
||||
❯ hooks-timeout.test.ts:79:47
|
||||
|
||||
FAIL |chromium| hooks-timeout.test.ts > timeouts are failing correctly > onTestFinished > fails
|
||||
TimeoutError: locator.click: Timeout <ms> exceeded.
|
||||
❯ hooks-timeout.test.ts:54:47
|
||||
|
||||
FAIL |chromium| hooks-timeout.test.ts > timeouts are failing correctly > onTestFinished > fails global
|
||||
TimeoutError: locator.click: Timeout <ms> exceeded.
|
||||
❯ hooks-timeout.test.ts:61:47
|
||||
|
||||
FAIL |firefox| hooks-timeout.test.ts > timeouts are failing correctly > afterAll
|
||||
TimeoutError: locator.click: Timeout <ms> exceeded.
|
||||
❯ hooks-timeout.test.ts:44:45
|
||||
|
||||
FAIL |firefox| hooks-timeout.test.ts > timeouts are failing correctly > afterEach > skipped
|
||||
TimeoutError: locator.click: Timeout <ms> exceeded.
|
||||
❯ hooks-timeout.test.ts:26:45
|
||||
|
||||
FAIL |firefox| hooks-timeout.test.ts > timeouts are failing correctly > beforeAll
|
||||
TimeoutError: locator.click: Timeout <ms> exceeded.
|
||||
❯ hooks-timeout.test.ts:35:45
|
||||
|
||||
FAIL |firefox| hooks-timeout.test.ts > timeouts are failing correctly > beforeEach > skipped
|
||||
TimeoutError: locator.click: Timeout <ms> exceeded.
|
||||
❯ hooks-timeout.test.ts:17:45
|
||||
|
||||
FAIL |firefox| hooks-timeout.test.ts > timeouts are failing correctly > click on non-existing element fails
|
||||
TimeoutError: locator.click: Timeout <ms> exceeded.
|
||||
❯ hooks-timeout.test.ts:7:33
|
||||
|
||||
FAIL |firefox| hooks-timeout.test.ts > timeouts are failing correctly > onTestFailed > fails
|
||||
TimeoutError: locator.click: Timeout <ms> exceeded.
|
||||
❯ hooks-timeout.test.ts:70:47
|
||||
|
||||
FAIL |firefox| hooks-timeout.test.ts > timeouts are failing correctly > onTestFailed > fails global
|
||||
TimeoutError: locator.click: Timeout <ms> exceeded.
|
||||
❯ hooks-timeout.test.ts:79:47
|
||||
|
||||
FAIL |firefox| hooks-timeout.test.ts > timeouts are failing correctly > onTestFinished > fails
|
||||
TimeoutError: locator.click: Timeout <ms> exceeded.
|
||||
❯ hooks-timeout.test.ts:54:47
|
||||
|
||||
FAIL |firefox| hooks-timeout.test.ts > timeouts are failing correctly > onTestFinished > fails global
|
||||
TimeoutError: locator.click: Timeout <ms> exceeded.
|
||||
❯ hooks-timeout.test.ts:61:47
|
||||
|
||||
FAIL |webkit| hooks-timeout.test.ts > timeouts are failing correctly > afterAll
|
||||
TimeoutError: locator.click: Timeout <ms> exceeded.
|
||||
❯ hooks-timeout.test.ts:44:45
|
||||
|
||||
FAIL |webkit| hooks-timeout.test.ts > timeouts are failing correctly > afterEach > skipped
|
||||
TimeoutError: locator.click: Timeout <ms> exceeded.
|
||||
❯ hooks-timeout.test.ts:26:45
|
||||
|
||||
FAIL |webkit| hooks-timeout.test.ts > timeouts are failing correctly > beforeAll
|
||||
TimeoutError: locator.click: Timeout <ms> exceeded.
|
||||
❯ hooks-timeout.test.ts:35:45
|
||||
|
||||
FAIL |webkit| hooks-timeout.test.ts > timeouts are failing correctly > beforeEach > skipped
|
||||
TimeoutError: locator.click: Timeout <ms> exceeded.
|
||||
❯ hooks-timeout.test.ts:17:45
|
||||
|
||||
FAIL |webkit| hooks-timeout.test.ts > timeouts are failing correctly > click on non-existing element fails
|
||||
TimeoutError: locator.click: Timeout <ms> exceeded.
|
||||
❯ hooks-timeout.test.ts:7:33
|
||||
|
||||
FAIL |webkit| hooks-timeout.test.ts > timeouts are failing correctly > onTestFailed > fails
|
||||
TimeoutError: locator.click: Timeout <ms> exceeded.
|
||||
❯ hooks-timeout.test.ts:70:47
|
||||
|
||||
FAIL |webkit| hooks-timeout.test.ts > timeouts are failing correctly > onTestFailed > fails global
|
||||
TimeoutError: locator.click: Timeout <ms> exceeded.
|
||||
❯ hooks-timeout.test.ts:79:47
|
||||
|
||||
FAIL |webkit| hooks-timeout.test.ts > timeouts are failing correctly > onTestFinished > fails
|
||||
TimeoutError: locator.click: Timeout <ms> exceeded.
|
||||
❯ hooks-timeout.test.ts:54:47
|
||||
|
||||
FAIL |webkit| hooks-timeout.test.ts > timeouts are failing correctly > onTestFinished > fails global
|
||||
TimeoutError: locator.click: Timeout <ms> exceeded.
|
||||
❯ hooks-timeout.test.ts:61:47"
|
||||
`)
|
||||
}
|
||||
else {
|
||||
expect(snapshot).toMatchInlineSnapshot(`
|
||||
" FAIL |chromium| hooks-timeout.test.ts > timeouts are failing correctly > afterAll
|
||||
TimeoutError: locator.click: Timeout <ms> exceeded.
|
||||
❯ hooks-timeout.test.ts:44:45
|
||||
@ -370,6 +484,7 @@ test.runIf(provider === 'playwright')('timeout hooks', async () => {
|
||||
TimeoutError: locator.click: Timeout <ms> exceeded.
|
||||
❯ hooks-timeout.test.ts:61:53"
|
||||
`)
|
||||
}
|
||||
|
||||
// page.getByRole('code').click()
|
||||
expect(stderr).toContain('locator.click: Timeout')
|
||||
|
||||
@ -2,6 +2,7 @@ import type { RunnerTaskResultPack, RunnerTestFile } from 'vitest'
|
||||
import type { UserConfig } from 'vitest/node'
|
||||
import { resolve } from 'pathe'
|
||||
import { expect, it } from 'vitest'
|
||||
import { rolldownVersion } from 'vitest/node'
|
||||
import { runVitest } from '../../test-utils'
|
||||
|
||||
it.each([
|
||||
@ -91,7 +92,9 @@ it.each([
|
||||
expect(files[0].tasks[index + 1].name).toBe(`custom ${name}`)
|
||||
expect(files[0].tasks[index + 1].location).toEqual({
|
||||
line: 18,
|
||||
column: 18,
|
||||
// TODO: rolldown is more correct, but regular vite's source map is
|
||||
// a little bit wrong with the boundaries (maybe because of the SSR transform?)
|
||||
column: rolldownVersion || config.browser?.enabled ? 18 : 17,
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { expect, test } from 'vitest'
|
||||
import { rolldownVersion } from 'vitest/node'
|
||||
import { runVitest } from '../../test-utils'
|
||||
|
||||
test('rollup error node', async () => {
|
||||
@ -7,7 +8,7 @@ test('rollup error node', async () => {
|
||||
environment: 'node',
|
||||
reporters: ['junit'],
|
||||
})
|
||||
expect(stdout).toContain(`Error: Missing "./no-such-export" specifier in "vite" package`)
|
||||
expect(stdout).toContain(`Error: Missing "./no-such-export" specifier in "${rolldownVersion ? 'rolldown-vite' : 'vite'}" package`)
|
||||
expect(stdout).toContain(`Plugin: vite:import-analysis`)
|
||||
expect(stdout).toContain(`Error: Failed to load url @vitejs/no-such-package`)
|
||||
})
|
||||
@ -18,7 +19,7 @@ test('rollup error web', async () => {
|
||||
environment: 'jsdom',
|
||||
reporters: ['junit'],
|
||||
})
|
||||
expect(stdout).toContain(`Error: Missing "./no-such-export" specifier in "vite" package`)
|
||||
expect(stdout).toContain(`Error: Missing "./no-such-export" specifier in "${rolldownVersion ? 'rolldown-vite' : 'vite'}" package`)
|
||||
expect(stdout).toContain(`Plugin: vite:import-analysis`)
|
||||
expect(stdout).toContain(`Error: Failed to resolve import "@vitejs/no-such-package" from "fixtures/rollup-error/not-found-package.test.ts". Does the file exist?`)
|
||||
})
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import { resolve } from 'node:path'
|
||||
import { expect, it } from 'vitest'
|
||||
import { getPackageExportsManifest } from 'vitest-package-exports'
|
||||
import { rolldownVersion } from 'vitest/node'
|
||||
|
||||
it('exports snapshot', async ({ skip, task }) => {
|
||||
skip(task.file.pool !== 'threads', 'run only once inside threads')
|
||||
@ -10,8 +11,9 @@ it('exports snapshot', async ({ skip, task }) => {
|
||||
cwd: resolve(import.meta.dirname, '../../../packages/vitest'),
|
||||
})
|
||||
|
||||
expect(manifest.exports)
|
||||
.toMatchInlineSnapshot(`
|
||||
if (rolldownVersion) {
|
||||
expect(manifest.exports)
|
||||
.toMatchInlineSnapshot(`
|
||||
{
|
||||
".": {
|
||||
"afterAll": "function",
|
||||
@ -110,6 +112,7 @@ it('exports snapshot', async ({ skip, task }) => {
|
||||
"resolveApiServerConfig": "function",
|
||||
"resolveConfig": "function",
|
||||
"resolveFsAllow": "function",
|
||||
"rolldownVersion": "string",
|
||||
"rollupVersion": "string",
|
||||
"rootDir": "string",
|
||||
"startVitest": "function",
|
||||
@ -163,4 +166,161 @@ it('exports snapshot', async ({ skip, task }) => {
|
||||
},
|
||||
}
|
||||
`)
|
||||
}
|
||||
else {
|
||||
expect(manifest.exports)
|
||||
.toMatchInlineSnapshot(`
|
||||
{
|
||||
".": {
|
||||
"afterAll": "function",
|
||||
"afterEach": "function",
|
||||
"assert": "function",
|
||||
"assertType": "function",
|
||||
"beforeAll": "function",
|
||||
"beforeEach": "function",
|
||||
"bench": "function",
|
||||
"chai": "object",
|
||||
"createExpect": "function",
|
||||
"describe": "function",
|
||||
"expect": "function",
|
||||
"expectTypeOf": "function",
|
||||
"inject": "function",
|
||||
"it": "function",
|
||||
"onTestFailed": "function",
|
||||
"onTestFinished": "function",
|
||||
"should": "function",
|
||||
"suite": "function",
|
||||
"test": "function",
|
||||
"vi": "object",
|
||||
"vitest": "object",
|
||||
},
|
||||
"./config": {
|
||||
"configDefaults": "object",
|
||||
"coverageConfigDefaults": "object",
|
||||
"defaultBrowserPort": "number",
|
||||
"defaultExclude": "object",
|
||||
"defaultInclude": "object",
|
||||
"defineConfig": "function",
|
||||
"defineProject": "function",
|
||||
"defineWorkspace": "function",
|
||||
"extraInlineDeps": "object",
|
||||
"mergeConfig": "function",
|
||||
},
|
||||
"./coverage": {
|
||||
"BaseCoverageProvider": "function",
|
||||
},
|
||||
"./environments": {
|
||||
"builtinEnvironments": "object",
|
||||
"populateGlobal": "function",
|
||||
},
|
||||
"./execute": {
|
||||
"VitestExecutor": "function",
|
||||
},
|
||||
"./internal/browser": {
|
||||
"SpyModule": "object",
|
||||
"TraceMap": "function",
|
||||
"collectTests": "function",
|
||||
"format": "function",
|
||||
"getSafeTimers": "function",
|
||||
"inspect": "function",
|
||||
"loadDiffConfig": "function",
|
||||
"loadSnapshotSerializers": "function",
|
||||
"originalPositionFor": "function",
|
||||
"processError": "function",
|
||||
"setupCommonEnv": "function",
|
||||
"startCoverageInsideWorker": "function",
|
||||
"startTests": "function",
|
||||
"stopCoverageInsideWorker": "function",
|
||||
"stringify": "function",
|
||||
"takeCoverageInsideWorker": "function",
|
||||
},
|
||||
"./mocker": {
|
||||
"AutomockedModule": "function",
|
||||
"AutospiedModule": "function",
|
||||
"ManualMockedModule": "function",
|
||||
"MockerRegistry": "function",
|
||||
"RedirectedModule": "function",
|
||||
"mockObject": "function",
|
||||
},
|
||||
"./node": {
|
||||
"BaseSequencer": "function",
|
||||
"GitNotFoundError": "function",
|
||||
"TestFile": "function",
|
||||
"TestsNotFoundError": "function",
|
||||
"VitestPackageInstaller": "function",
|
||||
"VitestPlugin": "function",
|
||||
"createDebugger": "function",
|
||||
"createMethodsRPC": "function",
|
||||
"createServer": "function",
|
||||
"createViteLogger": "function",
|
||||
"createViteServer": "function",
|
||||
"createVitest": "function",
|
||||
"distDir": "string",
|
||||
"esbuildVersion": "string",
|
||||
"generateFileHash": "function",
|
||||
"getFilePoolName": "function",
|
||||
"isFileServingAllowed": "function",
|
||||
"isValidApiRequest": "function",
|
||||
"parseAst": "function",
|
||||
"parseAstAsync": "function",
|
||||
"parseCLI": "function",
|
||||
"registerConsoleShortcuts": "function",
|
||||
"resolveApiServerConfig": "function",
|
||||
"resolveConfig": "function",
|
||||
"resolveFsAllow": "function",
|
||||
"rolldownVersion": "undefined",
|
||||
"rollupVersion": "string",
|
||||
"rootDir": "string",
|
||||
"startVitest": "function",
|
||||
"version": "string",
|
||||
"viteVersion": "string",
|
||||
},
|
||||
"./reporters": {
|
||||
"BasicReporter": "function",
|
||||
"BenchmarkReporter": "function",
|
||||
"BenchmarkReportsMap": "object",
|
||||
"DefaultReporter": "function",
|
||||
"DotReporter": "function",
|
||||
"GithubActionsReporter": "function",
|
||||
"HangingProcessReporter": "function",
|
||||
"JUnitReporter": "function",
|
||||
"JsonReporter": "function",
|
||||
"ReportersMap": "object",
|
||||
"TapFlatReporter": "function",
|
||||
"TapReporter": "function",
|
||||
"VerboseBenchmarkReporter": "function",
|
||||
"VerboseReporter": "function",
|
||||
},
|
||||
"./runners": {
|
||||
"NodeBenchmarkRunner": "function",
|
||||
"VitestTestRunner": "function",
|
||||
},
|
||||
"./snapshot": {
|
||||
"VitestSnapshotEnvironment": "function",
|
||||
},
|
||||
"./suite": {
|
||||
"createChainable": "function",
|
||||
"createTaskCollector": "function",
|
||||
"getBenchFn": "function",
|
||||
"getBenchOptions": "function",
|
||||
"getCurrentSuite": "function",
|
||||
"getCurrentTest": "function",
|
||||
"getFn": "function",
|
||||
"getHooks": "function",
|
||||
"setFn": "function",
|
||||
"setHooks": "function",
|
||||
},
|
||||
"./workers": {
|
||||
"collectVitestWorkerTests": "function",
|
||||
"createForksRpcOptions": "function",
|
||||
"createThreadsRpcOptions": "function",
|
||||
"provideWorkerState": "function",
|
||||
"runBaseTests": "function",
|
||||
"runVitestWorker": "function",
|
||||
"runVmTests": "function",
|
||||
"unwrapSerializableConfig": "function",
|
||||
},
|
||||
}
|
||||
`)
|
||||
}
|
||||
})
|
||||
|
||||
@ -2,7 +2,7 @@ import { parseAst } from 'vite'
|
||||
import { expect, test } from 'vitest'
|
||||
import { injectDynamicImport } from '../../../packages/mocker/src/node/dynamicImportPlugin'
|
||||
|
||||
function parse(code: string, options: any) {
|
||||
function parse(code: string, options: any): any {
|
||||
return parseAst(code, options)
|
||||
}
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@ import { describe, expect, it, test } from 'vitest'
|
||||
import { hoistMocks } from '../../../packages/mocker/src/node/hoistMocksPlugin'
|
||||
import { generateCodeFrame } from '../../../packages/vitest/src/node/printError.js'
|
||||
|
||||
function parse(code: string, options: any) {
|
||||
function parse(code: string, options: any): any {
|
||||
return parseAst(code, options)
|
||||
}
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@ import type { LabelColor } from 'vitest'
|
||||
import type { Pool } from 'vitest/node'
|
||||
import { basename, dirname, join, resolve } from 'pathe'
|
||||
import { defaultExclude, defineConfig } from 'vitest/config'
|
||||
import { rolldownVersion } from 'vitest/node'
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [
|
||||
@ -59,7 +60,13 @@ export default defineConfig({
|
||||
includeSource: [
|
||||
'src/in-source/*.ts',
|
||||
],
|
||||
exclude: ['**/fixtures/**', ...defaultExclude],
|
||||
exclude: [
|
||||
'**/fixtures/**',
|
||||
...defaultExclude,
|
||||
// FIXME: wait for ecma decorator support in rolldown/oxc
|
||||
// https://github.com/oxc-project/oxc/issues/9170
|
||||
...(rolldownVersion ? ['**/esnext.test.ts'] : []),
|
||||
],
|
||||
slowTestThreshold: 1000,
|
||||
testTimeout: process.env.CI ? 10_000 : 5_000,
|
||||
setupFiles: [
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import { readdirSync } from 'node:fs'
|
||||
import { resolve } from 'node:path'
|
||||
import { beforeAll, expect } from 'vitest'
|
||||
import { rolldownVersion } from 'vitest/node'
|
||||
import { isV8Provider, readCoverageMap, runVitest, test } from '../utils'
|
||||
|
||||
beforeAll(async () => {
|
||||
@ -23,7 +24,7 @@ test('files should not contain query parameters', () => {
|
||||
test('coverage results matches snapshot', async () => {
|
||||
const coverageMap = await readCoverageMap()
|
||||
|
||||
if (isV8Provider()) {
|
||||
if (isV8Provider() && !rolldownVersion) {
|
||||
expect(coverageMap).toMatchInlineSnapshot(`
|
||||
{
|
||||
"branches": "5/7 (71.42%)",
|
||||
@ -33,6 +34,16 @@ test('coverage results matches snapshot', async () => {
|
||||
}
|
||||
`)
|
||||
}
|
||||
else if (isV8Provider() && rolldownVersion) {
|
||||
expect(coverageMap).toMatchInlineSnapshot(`
|
||||
{
|
||||
"branches": "7/9 (77.77%)",
|
||||
"functions": "4/6 (66.66%)",
|
||||
"lines": "36/45 (80%)",
|
||||
"statements": "36/45 (80%)",
|
||||
}
|
||||
`)
|
||||
}
|
||||
else {
|
||||
expect(coverageMap).toMatchInlineSnapshot(`
|
||||
{
|
||||
|
||||
@ -49,6 +49,7 @@ it('redirect works correctly', async () => {
|
||||
async function createTestServer(config: UserConfig) {
|
||||
const server = await createServer({
|
||||
...config,
|
||||
cacheDir: '.cache',
|
||||
plugins: [
|
||||
mockerPlugin({
|
||||
globalThisAccessor: 'Symbol.for("vitest.mocker")',
|
||||
|
||||
@ -887,6 +887,7 @@ describe('merge reports', () => {
|
||||
}, {
|
||||
globals: true,
|
||||
reporters: [['blob', { outputFile: blobOutputFile1 }]],
|
||||
watch: false,
|
||||
})
|
||||
|
||||
const { root: root2 } = await runInlineTests({
|
||||
@ -902,10 +903,12 @@ describe('merge reports', () => {
|
||||
}, {
|
||||
globals: true,
|
||||
reporters: [['blob', { outputFile: blobOutputFile2 }]],
|
||||
watch: false,
|
||||
})
|
||||
|
||||
const report = await run({}, {
|
||||
mergeReports: blobsOutputDirectory,
|
||||
watch: false,
|
||||
}, {
|
||||
roots: [root1, root2],
|
||||
})
|
||||
|
||||
@ -3,7 +3,7 @@ import { defineConfig } from 'vitest/config'
|
||||
export default defineConfig({
|
||||
test: {
|
||||
watch: false,
|
||||
exclude: ['node_modules', 'fixtures', 'dist'],
|
||||
exclude: ['node_modules', 'fixtures', 'dist', '**/vitest-test-*/**'],
|
||||
reporters: ['verbose'],
|
||||
testTimeout: 100000,
|
||||
pool: 'forks',
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
import type { SourceMap } from 'rollup'
|
||||
/* eslint-disable no-template-curly-in-string */
|
||||
import type { TransformResult } from 'vite'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
@ -30,7 +29,6 @@ describe('withInlineSourcemap', () => {
|
||||
version: 3,
|
||||
mappings: 'AAAO,SAAS,IAAI,KAAqB;AACvC,SAAO,qDAAqD;AAC9D;iHAAA',
|
||||
names: [],
|
||||
sourceRoot: undefined,
|
||||
sources: [
|
||||
'/foo.ts',
|
||||
],
|
||||
@ -38,7 +36,8 @@ describe('withInlineSourcemap', () => {
|
||||
'export function foo(src: string): string {\n return `//# sourceMappingURL=data:application/json;base64,${src}`\n}\n',
|
||||
],
|
||||
file: '/src/foo.ts',
|
||||
} as unknown as SourceMap,
|
||||
toUrl: () => '',
|
||||
},
|
||||
deps: [
|
||||
],
|
||||
dynamicDeps: [
|
||||
|
||||
@ -14,6 +14,7 @@ export default defineConfig({
|
||||
projects: [
|
||||
'./space_*/*.config.ts',
|
||||
{
|
||||
cacheDir: '.cache/inline',
|
||||
test: {
|
||||
name: 'space_browser_inline',
|
||||
root: './space_browser_inline',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user