vitest
Advanced tools
Comparing version 0.34.1 to 0.34.2
export { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, suite, test } from '@vitest/runner'; | ||
export { e as bench, c as createExpect, d as expect, v as vi, f as vitest } from './vendor-vi.271667ef.js'; | ||
export { e as bench, c as createExpect, d as expect, v as vi, f as vitest } from './vendor-vi.f8055ff2.js'; | ||
export { i as isFirstRun, r as runOnce } from './vendor-run-once.3e5ef7d7.js'; | ||
import { d as dist } from './vendor-index.eff408fd.js'; | ||
export { b as assertType, g as getRunningMode, a as isWatchMode } from './vendor-index.eff408fd.js'; | ||
import { d as dist } from './vendor-index.b5efbd68.js'; | ||
export { b as assertType, g as getRunningMode, a as isWatchMode } from './vendor-index.b5efbd68.js'; | ||
import * as chai from 'chai'; | ||
@@ -19,3 +19,4 @@ export { chai }; | ||
import '@vitest/utils/error'; | ||
import './vendor-source-map.e6c1997b.js'; | ||
import './vendor-tasks.f9d75aed.js'; | ||
import '@vitest/utils/source-map'; | ||
import 'util'; | ||
@@ -22,0 +23,0 @@ import './vendor-date.6e993429.js'; |
export { startTests } from '@vitest/runner'; | ||
import { R as ResolvedConfig, C as CoverageOptions, a as CoverageProvider, b as CoverageProviderModule } from './types-3c7dbfa5.js'; | ||
import { R as ResolvedConfig, C as CoverageOptions, a as CoverageProvider, b as CoverageProviderModule } from './types-63abf2e0.js'; | ||
import '@vitest/snapshot'; | ||
@@ -4,0 +4,0 @@ import '@vitest/expect'; |
@@ -16,3 +16,3 @@ export { startTests } from '@vitest/runner'; | ||
if (config.globals) | ||
(await import('./chunk-integrations-globals.877c84db.js')).registerApiGlobally(); | ||
(await import('./chunk-integrations-globals.522ae1ae.js')).registerApiGlobally(); | ||
} | ||
@@ -19,0 +19,0 @@ function setupDefines(defines) { |
@@ -5,4 +5,4 @@ import { performance } from 'node:perf_hooks'; | ||
import { parseRegexp } from '@vitest/utils'; | ||
import { l as loadEnvironment } from './vendor-environments.443ecd82.js'; | ||
import { s as startViteNode, m as moduleCache, a as mockMap } from './vendor-execute.9ab1c1a7.js'; | ||
import { l as loadEnvironment } from './vendor-environments.37f266a9.js'; | ||
import { s as startViteNode, m as moduleCache, a as mockMap } from './vendor-execute.4fc8203a.js'; | ||
import { r as rpcDone, c as createSafeRpc } from './vendor-rpc.cbd8e972.js'; | ||
@@ -12,4 +12,12 @@ import { s as setupInspect } from './vendor-inspector.47fc8cbb.js'; | ||
import 'pathe'; | ||
import './vendor-index.0b5b3600.js'; | ||
import 'acorn'; | ||
import 'node:module'; | ||
import 'node:fs'; | ||
import 'node:assert'; | ||
import 'node:process'; | ||
import 'node:path'; | ||
import 'node:util'; | ||
import 'node:console'; | ||
import 'local-pkg'; | ||
import 'node:console'; | ||
import 'node:vm'; | ||
@@ -21,6 +29,3 @@ import 'vite-node/client'; | ||
import './vendor-global.97e4527c.js'; | ||
import 'node:fs'; | ||
import './vendor-base.9c08bbd0.js'; | ||
import 'node:path'; | ||
import 'node:module'; | ||
import 'vite-node/constants'; | ||
@@ -27,0 +32,0 @@ |
import { normalize } from 'pathe'; | ||
import cac from 'cac'; | ||
import c from 'picocolors'; | ||
import { v as version, s as startVitest, d as divider } from './vendor-node.caa511fc.js'; | ||
import { v as version, s as startVitest, d as divider } from './vendor-node.7b1bd3c5.js'; | ||
import './vendor-index.087d1af7.js'; | ||
@@ -36,4 +36,5 @@ import { t as toArray } from './vendor-base.9c08bbd0.js'; | ||
import 'node:perf_hooks'; | ||
import './vendor-source-map.e6c1997b.js'; | ||
import './vendor-tasks.f9d75aed.js'; | ||
import '@vitest/runner/utils'; | ||
import '@vitest/utils/source-map'; | ||
import 'node:module'; | ||
@@ -53,3 +54,5 @@ import 'node:crypto'; | ||
import 'strip-literal'; | ||
import './vendor-environments.443ecd82.js'; | ||
import './vendor-environments.37f266a9.js'; | ||
import './vendor-index.0b5b3600.js'; | ||
import 'node:assert'; | ||
import 'node:console'; | ||
@@ -56,0 +59,0 @@ import 'node:readline'; |
import { UserConfig as UserConfig$1, ConfigEnv } from 'vite'; | ||
export { ConfigEnv, UserConfig, mergeConfig } from 'vite'; | ||
import { c as ResolvedCoverageOptions, U as UserConfig, d as CoverageV8Options, P as ProjectConfig } from './types-3c7dbfa5.js'; | ||
import { c as ResolvedCoverageOptions, U as UserConfig, d as CoverageV8Options, P as ProjectConfig } from './types-63abf2e0.js'; | ||
import '@vitest/snapshot'; | ||
@@ -5,0 +5,0 @@ import '@vitest/expect'; |
@@ -1,2 +0,2 @@ | ||
import { B as BaseCoverageOptions, c as ResolvedCoverageOptions } from './types-3c7dbfa5.js'; | ||
import { B as BaseCoverageOptions, c as ResolvedCoverageOptions } from './types-63abf2e0.js'; | ||
import '@vitest/snapshot'; | ||
@@ -3,0 +3,0 @@ import '@vitest/expect'; |
@@ -9,3 +9,3 @@ import { isatty } from 'node:tty'; | ||
import { g as getWorkerState } from './vendor-global.97e4527c.js'; | ||
import { i as index } from './vendor-index.eff408fd.js'; | ||
import { i as index } from './vendor-index.b5efbd68.js'; | ||
import { setupCommonEnv } from './browser.js'; | ||
@@ -18,3 +18,3 @@ import 'chai'; | ||
import './vendor-rpc.cbd8e972.js'; | ||
import './vendor-vi.271667ef.js'; | ||
import './vendor-vi.f8055ff2.js'; | ||
import '@vitest/runner/utils'; | ||
@@ -27,3 +27,4 @@ import './vendor-index.087d1af7.js'; | ||
import '@vitest/utils/error'; | ||
import './vendor-source-map.e6c1997b.js'; | ||
import './vendor-tasks.f9d75aed.js'; | ||
import '@vitest/utils/source-map'; | ||
import 'util'; | ||
@@ -30,0 +31,0 @@ import './vendor-date.6e993429.js'; |
import { performance } from 'node:perf_hooks'; | ||
import { startTests } from '@vitest/runner'; | ||
import './vendor-index.087d1af7.js'; | ||
import { d as globalExpect, r as resetModules, v as vi } from './vendor-vi.271667ef.js'; | ||
import { d as globalExpect, r as resetModules, v as vi } from './vendor-vi.f8055ff2.js'; | ||
import { s as startCoverageInsideWorker, a as stopCoverageInsideWorker } from './vendor-coverage.78040316.js'; | ||
@@ -11,3 +11,3 @@ import { V as VitestSnapshotEnvironment, s as setupChaiConfig, r as resolveTestRunner } from './vendor-index.9378c9a4.js'; | ||
import { setupColors, createColors, getSafeTimers } from '@vitest/utils'; | ||
import { i as index } from './vendor-index.eff408fd.js'; | ||
import { i as index } from './vendor-index.b5efbd68.js'; | ||
import { setupCommonEnv } from './browser.js'; | ||
@@ -23,3 +23,4 @@ import { g as getWorkerState } from './vendor-global.97e4527c.js'; | ||
import '@vitest/utils/error'; | ||
import './vendor-source-map.e6c1997b.js'; | ||
import './vendor-tasks.f9d75aed.js'; | ||
import '@vitest/utils/source-map'; | ||
import 'util'; | ||
@@ -26,0 +27,0 @@ import './vendor-date.6e993429.js'; |
@@ -1,2 +0,2 @@ | ||
import { E as Environment } from './types-3c7dbfa5.js'; | ||
import { E as Environment } from './types-63abf2e0.js'; | ||
import '@vitest/snapshot'; | ||
@@ -3,0 +3,0 @@ import '@vitest/expect'; |
@@ -1,5 +0,14 @@ | ||
export { e as builtinEnvironments, p as populateGlobal } from './vendor-environments.443ecd82.js'; | ||
export { e as builtinEnvironments, p as populateGlobal } from './vendor-environments.37f266a9.js'; | ||
import 'node:url'; | ||
import 'pathe'; | ||
import './vendor-index.0b5b3600.js'; | ||
import 'acorn'; | ||
import 'node:module'; | ||
import 'node:fs'; | ||
import 'node:assert'; | ||
import 'node:process'; | ||
import 'node:path'; | ||
import 'node:v8'; | ||
import 'node:util'; | ||
import 'node:console'; | ||
import 'local-pkg'; | ||
import 'node:console'; |
@@ -1,2 +0,2 @@ | ||
export { V as VitestExecutor } from './vendor-execute.9ab1c1a7.js'; | ||
export { V as VitestExecutor } from './vendor-execute.4fc8203a.js'; | ||
import 'node:url'; | ||
@@ -3,0 +3,0 @@ import 'node:vm'; |
import { Test, File, TaskResultPack, CancelReason } from '@vitest/runner'; | ||
export { DoneCallback, File, HookCleanupCallback, HookListener, OnTestFailedHandler, RunMode, RuntimeContext, SequenceHooks, SequenceSetupFiles, Suite, SuiteAPI, SuiteCollector, SuiteFactory, SuiteHooks, Task, TaskBase, TaskMeta, TaskResult, TaskResultPack, TaskState, Test, TestAPI, TestContext, TestFunction, TestOptions, afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, suite, test } from '@vitest/runner'; | ||
import { h as BenchmarkAPI, F as FakeTimerInstallOpts, M as MockFactoryWithHelper, i as RuntimeConfig, A as AfterSuiteRunMeta, j as UserConsoleLog, R as ResolvedConfig, k as ModuleGraphData, l as Reporter } from './types-3c7dbfa5.js'; | ||
export { x as ApiConfig, a0 as ArgumentsType, $ as Arrayable, Z as Awaitable, B as BaseCoverageOptions, ae as BenchFunction, ac as Benchmark, ad as BenchmarkResult, ab as BenchmarkUserOptions, t as BuiltinEnvironment, w as CSSModuleScopeStrategy, o as CollectLineNumbers, p as CollectLines, a2 as Constructable, r as Context, O as ContextRPC, L as ContextTestEnvironment, a9 as CoverageIstanbulOptions, C as CoverageOptions, a as CoverageProvider, b as CoverageProviderModule, a8 as CoverageReporter, d as CoverageV8Options, aa as CustomProviderOptions, D as DepsOptimizationOptions, E as Environment, y as EnvironmentOptions, a4 as EnvironmentReturn, I as InlineConfig, J as JSDOMOptions, a3 as ModuleCache, a1 as MutableArray, _ as Nullable, a6 as OnServerRestartHandler, P as ProjectConfig, m as RawErrsMap, a7 as ReportContext, S as ResolveIdFunction, c as ResolvedCoverageOptions, N as ResolvedTestEnvironment, q as RootAndTarget, K as RunnerRPC, H as RuntimeRPC, z as TransformModePatterns, n as TscErrorInfo, G as TypecheckConfig, U as UserConfig, e as Vitest, u as VitestEnvironment, v as VitestPool, V as VitestRunMode, a5 as VmEnvironmentReturn, Q as WorkerContext, Y as WorkerGlobalState, X as WorkerRPC } from './types-3c7dbfa5.js'; | ||
import { l as BenchmarkAPI, F as FakeTimerInstallOpts, m as MockFactoryWithHelper, n as RuntimeConfig, A as AfterSuiteRunMeta, o as UserConsoleLog, R as ResolvedConfig, p as ModuleGraphData, q as Reporter } from './types-63abf2e0.js'; | ||
export { I as ApiConfig, a4 as ArgumentsType, a3 as Arrayable, a1 as Awaitable, B as BaseCoverageOptions, ai as BenchFunction, ag as Benchmark, ah as BenchmarkResult, af as BenchmarkUserOptions, y as BuiltinEnvironment, G as CSSModuleScopeStrategy, u as CollectLineNumbers, v as CollectLines, a6 as Constructable, x as Context, Z as ContextRPC, X as ContextTestEnvironment, ad as CoverageIstanbulOptions, C as CoverageOptions, a as CoverageProvider, b as CoverageProviderModule, ac as CoverageReporter, d as CoverageV8Options, ae as CustomProviderOptions, L as DepsOptimizationOptions, E as Environment, K as EnvironmentOptions, a8 as EnvironmentReturn, H as HappyDOMOptions, O as InlineConfig, J as JSDOMOptions, a7 as ModuleCache, a5 as MutableArray, a2 as Nullable, aa as OnServerRestartHandler, P as ProjectConfig, r as RawErrsMap, ab as ReportContext, $ as ResolveIdFunction, c as ResolvedCoverageOptions, Y as ResolvedTestEnvironment, w as RootAndTarget, S as RunnerRPC, k as RuntimeRPC, N as TransformModePatterns, t as TscErrorInfo, Q as TypecheckConfig, U as UserConfig, e as Vitest, z as VitestEnvironment, D as VitestPool, V as VitestRunMode, a9 as VmEnvironmentReturn, _ as WorkerContext, i as WorkerGlobalState, a0 as WorkerRPC } from './types-63abf2e0.js'; | ||
import { ExpectStatic } from '@vitest/expect'; | ||
@@ -319,3 +319,3 @@ export { Assertion, AsymmetricMatchersContaining, ExpectStatic, JestAssertion } from '@vitest/expect'; | ||
* Useful, if you want to have global variables available, like `IntersectionObserver`. | ||
* You can return it back to original value with `vi.unstubGlobals`, or by enabling `unstubGlobals` config option. | ||
* You can return it back to original value with `vi.unstubAllGlobals`, or by enabling `unstubGlobals` config option. | ||
*/ | ||
@@ -325,3 +325,3 @@ stubGlobal(name: string | symbol | number, value: unknown): this; | ||
* Changes the value of `import.meta.env` and `process.env`. | ||
* You can return it back to original value with `vi.unstubEnvs`, or by enabling `unstubEnvs` config option. | ||
* You can return it back to original value with `vi.unstubAllEnvs`, or by enabling `unstubEnvs` config option. | ||
*/ | ||
@@ -356,3 +356,3 @@ stubEnv(name: string, value: string): this; | ||
declare function getRunningMode(): "watch" | "run"; | ||
declare function getRunningMode(): "run" | "watch"; | ||
declare function isWatchMode(): boolean; | ||
@@ -378,6 +378,7 @@ | ||
getTransformResult(id: string): Promise<TransformResultWithSource | undefined>; | ||
readFile(id: string): Promise<string | null>; | ||
writeFile(id: string, content: string, ensureDir?: boolean): Promise<void>; | ||
removeFile(id: string): Promise<void>; | ||
createDirectory(id: string): Promise<string | undefined>; | ||
readSnapshotFile(id: string): Promise<string | null>; | ||
readTestFile(id: string): Promise<string | null>; | ||
saveTestFile(id: string, content: string): Promise<void>; | ||
saveSnapshotFile(id: string, content: string): Promise<void>; | ||
removeSnapshotFile(id: string): Promise<void>; | ||
snapshotSaved(snapshot: SnapshotResult): void; | ||
@@ -384,0 +385,0 @@ rerun(files: string[]): Promise<void>; |
export { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, suite, test } from '@vitest/runner'; | ||
export { e as bench, c as createExpect, d as expect, v as vi, f as vitest } from './vendor-vi.271667ef.js'; | ||
export { e as bench, c as createExpect, d as expect, v as vi, f as vitest } from './vendor-vi.f8055ff2.js'; | ||
export { i as isFirstRun, r as runOnce } from './vendor-run-once.3e5ef7d7.js'; | ||
import { d as dist } from './vendor-index.eff408fd.js'; | ||
export { b as assertType, g as getRunningMode, a as isWatchMode } from './vendor-index.eff408fd.js'; | ||
import { d as dist } from './vendor-index.b5efbd68.js'; | ||
export { b as assertType, g as getRunningMode, a as isWatchMode } from './vendor-index.b5efbd68.js'; | ||
import * as chai from 'chai'; | ||
@@ -19,3 +19,4 @@ export { chai }; | ||
import '@vitest/utils/error'; | ||
import './vendor-source-map.e6c1997b.js'; | ||
import './vendor-tasks.f9d75aed.js'; | ||
import '@vitest/utils/source-map'; | ||
import 'util'; | ||
@@ -22,0 +23,0 @@ import './vendor-date.6e993429.js'; |
import { pathToFileURL, fileURLToPath } from 'node:url'; | ||
import { readFile } from 'node:fs/promises'; | ||
import { i as isNodeBuiltin, h as hasCJSSyntax } from './vendor-index.0b5b3600.js'; | ||
import { normalizeModuleId } from 'vite-node/utils'; | ||
import './vendor-index.087d1af7.js'; | ||
import { g as getWorkerState } from './vendor-global.97e4527c.js'; | ||
import 'acorn'; | ||
import { builtinModules } from 'node:module'; | ||
import 'node:module'; | ||
import 'node:fs'; | ||
import 'pathe'; | ||
import assert from 'node:assert'; | ||
import process$1 from 'node:process'; | ||
import 'node:assert'; | ||
import 'node:process'; | ||
import 'node:path'; | ||
import v8 from 'node:v8'; | ||
import { format, inspect } from 'node:util'; | ||
import { normalizeModuleId } from 'vite-node/utils'; | ||
import './vendor-index.087d1af7.js'; | ||
import { g as getWorkerState } from './vendor-global.97e4527c.js'; | ||
import 'node:v8'; | ||
import 'node:util'; | ||
import 'std-env'; | ||
@@ -19,522 +20,2 @@ import '@vitest/runner/utils'; | ||
const BUILTIN_MODULES = new Set(builtinModules); | ||
/** | ||
* @typedef ErrnoExceptionFields | ||
* @property {number | undefined} [errnode] | ||
* @property {string | undefined} [code] | ||
* @property {string | undefined} [path] | ||
* @property {string | undefined} [syscall] | ||
* @property {string | undefined} [url] | ||
* | ||
* @typedef {Error & ErrnoExceptionFields} ErrnoException | ||
*/ | ||
const isWindows = process$1.platform === 'win32'; | ||
const own$1 = {}.hasOwnProperty; | ||
const classRegExp = /^([A-Z][a-z\d]*)+$/; | ||
// Sorted by a rough estimate on most frequently used entries. | ||
const kTypes = new Set([ | ||
'string', | ||
'function', | ||
'number', | ||
'object', | ||
// Accept 'Function' and 'Object' as alternative to the lower cased version. | ||
'Function', | ||
'Object', | ||
'boolean', | ||
'bigint', | ||
'symbol' | ||
]); | ||
/** | ||
* Create a list string in the form like 'A and B' or 'A, B, ..., and Z'. | ||
* We cannot use Intl.ListFormat because it's not available in | ||
* --without-intl builds. | ||
* | ||
* @param {Array<string>} array | ||
* An array of strings. | ||
* @param {string} [type] | ||
* The list type to be inserted before the last element. | ||
* @returns {string} | ||
*/ | ||
function formatList(array, type = 'and') { | ||
return array.length < 3 | ||
? array.join(` ${type} `) | ||
: `${array.slice(0, -1).join(', ')}, ${type} ${array[array.length - 1]}` | ||
} | ||
/** @type {Map<string, MessageFunction | string>} */ | ||
const messages = new Map(); | ||
const nodeInternalPrefix = '__node_internal_'; | ||
/** @type {number} */ | ||
let userStackTraceLimit; | ||
createError( | ||
'ERR_INVALID_ARG_TYPE', | ||
/** | ||
* @param {string} name | ||
* @param {Array<string> | string} expected | ||
* @param {unknown} actual | ||
*/ | ||
(name, expected, actual) => { | ||
assert(typeof name === 'string', "'name' must be a string"); | ||
if (!Array.isArray(expected)) { | ||
expected = [expected]; | ||
} | ||
let message = 'The '; | ||
if (name.endsWith(' argument')) { | ||
// For cases like 'first argument' | ||
message += `${name} `; | ||
} else { | ||
const type = name.includes('.') ? 'property' : 'argument'; | ||
message += `"${name}" ${type} `; | ||
} | ||
message += 'must be '; | ||
/** @type {Array<string>} */ | ||
const types = []; | ||
/** @type {Array<string>} */ | ||
const instances = []; | ||
/** @type {Array<string>} */ | ||
const other = []; | ||
for (const value of expected) { | ||
assert( | ||
typeof value === 'string', | ||
'All expected entries have to be of type string' | ||
); | ||
if (kTypes.has(value)) { | ||
types.push(value.toLowerCase()); | ||
} else if (classRegExp.exec(value) === null) { | ||
assert( | ||
value !== 'object', | ||
'The value "object" should be written as "Object"' | ||
); | ||
other.push(value); | ||
} else { | ||
instances.push(value); | ||
} | ||
} | ||
// Special handle `object` in case other instances are allowed to outline | ||
// the differences between each other. | ||
if (instances.length > 0) { | ||
const pos = types.indexOf('object'); | ||
if (pos !== -1) { | ||
types.slice(pos, 1); | ||
instances.push('Object'); | ||
} | ||
} | ||
if (types.length > 0) { | ||
message += `${types.length > 1 ? 'one of type' : 'of type'} ${formatList( | ||
types, | ||
'or' | ||
)}`; | ||
if (instances.length > 0 || other.length > 0) message += ' or '; | ||
} | ||
if (instances.length > 0) { | ||
message += `an instance of ${formatList(instances, 'or')}`; | ||
if (other.length > 0) message += ' or '; | ||
} | ||
if (other.length > 0) { | ||
if (other.length > 1) { | ||
message += `one of ${formatList(other, 'or')}`; | ||
} else { | ||
if (other[0].toLowerCase() !== other[0]) message += 'an '; | ||
message += `${other[0]}`; | ||
} | ||
} | ||
message += `. Received ${determineSpecificType(actual)}`; | ||
return message | ||
}, | ||
TypeError | ||
); | ||
createError( | ||
'ERR_INVALID_MODULE_SPECIFIER', | ||
/** | ||
* @param {string} request | ||
* @param {string} reason | ||
* @param {string} [base] | ||
*/ | ||
(request, reason, base = undefined) => { | ||
return `Invalid module "${request}" ${reason}${ | ||
base ? ` imported from ${base}` : '' | ||
}` | ||
}, | ||
TypeError | ||
); | ||
createError( | ||
'ERR_INVALID_PACKAGE_CONFIG', | ||
/** | ||
* @param {string} path | ||
* @param {string} [base] | ||
* @param {string} [message] | ||
*/ | ||
(path, base, message) => { | ||
return `Invalid package config ${path}${ | ||
base ? ` while importing ${base}` : '' | ||
}${message ? `. ${message}` : ''}` | ||
}, | ||
Error | ||
); | ||
createError( | ||
'ERR_INVALID_PACKAGE_TARGET', | ||
/** | ||
* @param {string} pkgPath | ||
* @param {string} key | ||
* @param {unknown} target | ||
* @param {boolean} [isImport=false] | ||
* @param {string} [base] | ||
*/ | ||
(pkgPath, key, target, isImport = false, base = undefined) => { | ||
const relError = | ||
typeof target === 'string' && | ||
!isImport && | ||
target.length > 0 && | ||
!target.startsWith('./'); | ||
if (key === '.') { | ||
assert(isImport === false); | ||
return ( | ||
`Invalid "exports" main target ${JSON.stringify(target)} defined ` + | ||
`in the package config ${pkgPath}package.json${ | ||
base ? ` imported from ${base}` : '' | ||
}${relError ? '; targets must start with "./"' : ''}` | ||
) | ||
} | ||
return `Invalid "${ | ||
isImport ? 'imports' : 'exports' | ||
}" target ${JSON.stringify( | ||
target | ||
)} defined for '${key}' in the package config ${pkgPath}package.json${ | ||
base ? ` imported from ${base}` : '' | ||
}${relError ? '; targets must start with "./"' : ''}` | ||
}, | ||
Error | ||
); | ||
createError( | ||
'ERR_MODULE_NOT_FOUND', | ||
/** | ||
* @param {string} path | ||
* @param {string} base | ||
* @param {string} [type] | ||
*/ | ||
(path, base, type = 'package') => { | ||
return `Cannot find ${type} '${path}' imported from ${base}` | ||
}, | ||
Error | ||
); | ||
createError( | ||
'ERR_NETWORK_IMPORT_DISALLOWED', | ||
"import of '%s' by %s is not supported: %s", | ||
Error | ||
); | ||
createError( | ||
'ERR_PACKAGE_IMPORT_NOT_DEFINED', | ||
/** | ||
* @param {string} specifier | ||
* @param {string} packagePath | ||
* @param {string} base | ||
*/ | ||
(specifier, packagePath, base) => { | ||
return `Package import specifier "${specifier}" is not defined${ | ||
packagePath ? ` in package ${packagePath}package.json` : '' | ||
} imported from ${base}` | ||
}, | ||
TypeError | ||
); | ||
createError( | ||
'ERR_PACKAGE_PATH_NOT_EXPORTED', | ||
/** | ||
* @param {string} pkgPath | ||
* @param {string} subpath | ||
* @param {string} [base] | ||
*/ | ||
(pkgPath, subpath, base = undefined) => { | ||
if (subpath === '.') | ||
return `No "exports" main defined in ${pkgPath}package.json${ | ||
base ? ` imported from ${base}` : '' | ||
}` | ||
return `Package subpath '${subpath}' is not defined by "exports" in ${pkgPath}package.json${ | ||
base ? ` imported from ${base}` : '' | ||
}` | ||
}, | ||
Error | ||
); | ||
createError( | ||
'ERR_UNSUPPORTED_DIR_IMPORT', | ||
"Directory import '%s' is not supported " + | ||
'resolving ES modules imported from %s', | ||
Error | ||
); | ||
createError( | ||
'ERR_UNKNOWN_FILE_EXTENSION', | ||
/** | ||
* @param {string} ext | ||
* @param {string} path | ||
*/ | ||
(ext, path) => { | ||
return `Unknown file extension "${ext}" for ${path}` | ||
}, | ||
TypeError | ||
); | ||
createError( | ||
'ERR_INVALID_ARG_VALUE', | ||
/** | ||
* @param {string} name | ||
* @param {unknown} value | ||
* @param {string} [reason='is invalid'] | ||
*/ | ||
(name, value, reason = 'is invalid') => { | ||
let inspected = inspect(value); | ||
if (inspected.length > 128) { | ||
inspected = `${inspected.slice(0, 128)}...`; | ||
} | ||
const type = name.includes('.') ? 'property' : 'argument'; | ||
return `The ${type} '${name}' ${reason}. Received ${inspected}` | ||
}, | ||
TypeError | ||
// Note: extra classes have been shaken out. | ||
// , RangeError | ||
); | ||
createError( | ||
'ERR_UNSUPPORTED_ESM_URL_SCHEME', | ||
/** | ||
* @param {URL} url | ||
* @param {Array<string>} supported | ||
*/ | ||
(url, supported) => { | ||
let message = `Only URLs with a scheme in: ${formatList( | ||
supported | ||
)} are supported by the default ESM loader`; | ||
if (isWindows && url.protocol.length === 2) { | ||
message += '. On Windows, absolute paths must be valid file:// URLs'; | ||
} | ||
message += `. Received protocol '${url.protocol}'`; | ||
return message | ||
}, | ||
Error | ||
); | ||
/** | ||
* Utility function for registering the error codes. Only used here. Exported | ||
* *only* to allow for testing. | ||
* @param {string} sym | ||
* @param {MessageFunction | string} value | ||
* @param {ErrorConstructor} def | ||
* @returns {new (...args: Array<any>) => Error} | ||
*/ | ||
function createError(sym, value, def) { | ||
// Special case for SystemError that formats the error message differently | ||
// The SystemErrors only have SystemError as their base classes. | ||
messages.set(sym, value); | ||
return makeNodeErrorWithCode(def, sym) | ||
} | ||
/** | ||
* @param {ErrorConstructor} Base | ||
* @param {string} key | ||
* @returns {ErrorConstructor} | ||
*/ | ||
function makeNodeErrorWithCode(Base, key) { | ||
// @ts-expect-error It’s a Node error. | ||
return NodeError | ||
/** | ||
* @param {Array<unknown>} args | ||
*/ | ||
function NodeError(...args) { | ||
const limit = Error.stackTraceLimit; | ||
if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = 0; | ||
const error = new Base(); | ||
// Reset the limit and setting the name property. | ||
if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = limit; | ||
const message = getMessage(key, args, error); | ||
Object.defineProperties(error, { | ||
// Note: no need to implement `kIsNodeError` symbol, would be hard, | ||
// probably. | ||
message: { | ||
value: message, | ||
enumerable: false, | ||
writable: true, | ||
configurable: true | ||
}, | ||
toString: { | ||
/** @this {Error} */ | ||
value() { | ||
return `${this.name} [${key}]: ${this.message}` | ||
}, | ||
enumerable: false, | ||
writable: true, | ||
configurable: true | ||
} | ||
}); | ||
captureLargerStackTrace(error); | ||
// @ts-expect-error It’s a Node error. | ||
error.code = key; | ||
return error | ||
} | ||
} | ||
/** | ||
* @returns {boolean} | ||
*/ | ||
function isErrorStackTraceLimitWritable() { | ||
// Do no touch Error.stackTraceLimit as V8 would attempt to install | ||
// it again during deserialization. | ||
try { | ||
// @ts-expect-error: not in types? | ||
if (v8.startupSnapshot.isBuildingSnapshot()) { | ||
return false | ||
} | ||
} catch {} | ||
const desc = Object.getOwnPropertyDescriptor(Error, 'stackTraceLimit'); | ||
if (desc === undefined) { | ||
return Object.isExtensible(Error) | ||
} | ||
return own$1.call(desc, 'writable') && desc.writable !== undefined | ||
? desc.writable | ||
: desc.set !== undefined | ||
} | ||
/** | ||
* This function removes unnecessary frames from Node.js core errors. | ||
* @template {(...args: unknown[]) => unknown} T | ||
* @param {T} fn | ||
* @returns {T} | ||
*/ | ||
function hideStackFrames(fn) { | ||
// We rename the functions that will be hidden to cut off the stacktrace | ||
// at the outermost one | ||
const hidden = nodeInternalPrefix + fn.name; | ||
Object.defineProperty(fn, 'name', {value: hidden}); | ||
return fn | ||
} | ||
const captureLargerStackTrace = hideStackFrames( | ||
/** | ||
* @param {Error} error | ||
* @returns {Error} | ||
*/ | ||
// @ts-expect-error: fine | ||
function (error) { | ||
const stackTraceLimitIsWritable = isErrorStackTraceLimitWritable(); | ||
if (stackTraceLimitIsWritable) { | ||
userStackTraceLimit = Error.stackTraceLimit; | ||
Error.stackTraceLimit = Number.POSITIVE_INFINITY; | ||
} | ||
Error.captureStackTrace(error); | ||
// Reset the limit | ||
if (stackTraceLimitIsWritable) Error.stackTraceLimit = userStackTraceLimit; | ||
return error | ||
} | ||
); | ||
/** | ||
* @param {string} key | ||
* @param {Array<unknown>} args | ||
* @param {Error} self | ||
* @returns {string} | ||
*/ | ||
function getMessage(key, args, self) { | ||
const message = messages.get(key); | ||
assert(message !== undefined, 'expected `message` to be found'); | ||
if (typeof message === 'function') { | ||
assert( | ||
message.length <= args.length, // Default options do not count. | ||
`Code: ${key}; The provided arguments length (${args.length}) does not ` + | ||
`match the required ones (${message.length}).` | ||
); | ||
return Reflect.apply(message, self, args) | ||
} | ||
const regex = /%[dfijoOs]/g; | ||
let expectedLength = 0; | ||
while (regex.exec(message) !== null) expectedLength++; | ||
assert( | ||
expectedLength === args.length, | ||
`Code: ${key}; The provided arguments length (${args.length}) does not ` + | ||
`match the required ones (${expectedLength}).` | ||
); | ||
if (args.length === 0) return message | ||
args.unshift(message); | ||
return Reflect.apply(format, null, args) | ||
} | ||
/** | ||
* Determine the specific type of a value for type-mismatch errors. | ||
* @param {unknown} value | ||
* @returns {string} | ||
*/ | ||
function determineSpecificType(value) { | ||
if (value === null || value === undefined) { | ||
return String(value) | ||
} | ||
if (typeof value === 'function' && value.name) { | ||
return `function ${value.name}` | ||
} | ||
if (typeof value === 'object') { | ||
if (value.constructor && value.constructor.name) { | ||
return `an instance of ${value.constructor.name}` | ||
} | ||
return `${inspect(value, {depth: -1})}` | ||
} | ||
let inspected = inspect(value, {colors: false}); | ||
if (inspected.length > 28) { | ||
inspected = `${inspected.slice(0, 25)}...`; | ||
} | ||
return `type ${typeof value} (${inspected})` | ||
} | ||
function isNodeBuiltin(id = "") { | ||
id = id.replace(/^node:/, "").split("/")[0]; | ||
return BUILTIN_MODULES.has(id); | ||
} | ||
pathToFileURL(process.cwd()); | ||
const CJS_RE = /([\s;]|^)(module.exports\b|exports\.\w|require\s*\(|global\.\w)/m; | ||
function hasCJSSyntax(code) { | ||
return CJS_RE.test(code); | ||
} | ||
var ModuleFormat = /* @__PURE__ */ ((ModuleFormat2) => { | ||
@@ -541,0 +22,0 @@ ModuleFormat2["Builtin"] = "builtin"; |
@@ -1,3 +0,3 @@ | ||
import { V as VitestRunMode, U as UserConfig, e as Vitest, T as TestSequencer, W as WorkspaceSpec } from './types-3c7dbfa5.js'; | ||
export { g as TestSequencerConstructor, f as VitestWorkspace, s as startVitest } from './types-3c7dbfa5.js'; | ||
import { V as VitestRunMode, U as UserConfig, e as Vitest, T as TestSequencer, W as WorkspaceSpec } from './types-63abf2e0.js'; | ||
export { g as TestSequencerConstructor, f as VitestWorkspace, s as startVitest } from './types-63abf2e0.js'; | ||
import { UserConfig as UserConfig$1, Plugin } from 'vite'; | ||
@@ -4,0 +4,0 @@ import '@vitest/snapshot'; |
@@ -1,2 +0,2 @@ | ||
export { B as BaseSequencer, V as VitestPlugin, c as createVitest, r as registerConsoleShortcuts, s as startVitest } from './vendor-node.caa511fc.js'; | ||
export { B as BaseSequencer, V as VitestPlugin, c as createVitest, r as registerConsoleShortcuts, s as startVitest } from './vendor-node.7b1bd3c5.js'; | ||
import 'pathe'; | ||
@@ -37,3 +37,4 @@ import 'vite'; | ||
import 'node:perf_hooks'; | ||
import './vendor-source-map.e6c1997b.js'; | ||
import './vendor-tasks.f9d75aed.js'; | ||
import '@vitest/utils/source-map'; | ||
import 'node:module'; | ||
@@ -53,5 +54,7 @@ import 'node:crypto'; | ||
import 'strip-literal'; | ||
import './vendor-environments.443ecd82.js'; | ||
import './vendor-environments.37f266a9.js'; | ||
import './vendor-index.0b5b3600.js'; | ||
import 'node:assert'; | ||
import 'node:console'; | ||
import 'node:readline'; | ||
import 'readline'; |
import { VitestRunner, VitestRunnerImportSource, Suite, Test, CancelReason, TestContext } from '@vitest/runner'; | ||
import { R as ResolvedConfig } from './types-3c7dbfa5.js'; | ||
import { R as ResolvedConfig } from './types-63abf2e0.js'; | ||
import '@vitest/snapshot'; | ||
@@ -4,0 +4,0 @@ import '@vitest/expect'; |
import { setState, GLOBAL_EXPECT, getState } from '@vitest/expect'; | ||
import { g as getSnapshotClient, c as createExpect, v as vi, a as getBenchOptions, b as getBenchFn } from './vendor-vi.271667ef.js'; | ||
import { g as getSnapshotClient, c as createExpect, v as vi, a as getBenchOptions, b as getBenchFn } from './vendor-vi.f8055ff2.js'; | ||
import './vendor-index.087d1af7.js'; | ||
import { a as rpc } from './vendor-rpc.cbd8e972.js'; | ||
import { g as getFullName } from './vendor-source-map.e6c1997b.js'; | ||
import { g as getFullName } from './vendor-tasks.f9d75aed.js'; | ||
import { g as getWorkerState } from './vendor-global.97e4527c.js'; | ||
@@ -15,2 +15,3 @@ import { getNames } from '@vitest/runner/utils'; | ||
import '@vitest/utils/error'; | ||
import '@vitest/utils/source-map'; | ||
import 'util'; | ||
@@ -17,0 +18,0 @@ import './vendor-date.6e993429.js'; |
@@ -10,16 +10,22 @@ import { pathToFileURL } from 'node:url'; | ||
import { d as distDir } from './vendor-paths.84fc7a99.js'; | ||
import { l as loadEnvironment } from './vendor-environments.443ecd82.js'; | ||
import { b as startVitestExecutor } from './vendor-execute.9ab1c1a7.js'; | ||
import { l as loadEnvironment } from './vendor-environments.37f266a9.js'; | ||
import { b as startVitestExecutor } from './vendor-execute.4fc8203a.js'; | ||
import { createCustomConsole } from './chunk-runtime-console.ea222ffb.js'; | ||
import { c as createSafeRpc } from './vendor-rpc.cbd8e972.js'; | ||
import './vendor-index.0b5b3600.js'; | ||
import 'acorn'; | ||
import 'node:module'; | ||
import 'node:fs'; | ||
import 'node:assert'; | ||
import 'node:process'; | ||
import 'node:path'; | ||
import 'node:v8'; | ||
import 'node:util'; | ||
import 'node:console'; | ||
import 'local-pkg'; | ||
import 'node:console'; | ||
import 'vite-node/utils'; | ||
import '@vitest/utils/error'; | ||
import './vendor-global.97e4527c.js'; | ||
import 'node:fs'; | ||
import '@vitest/utils'; | ||
import './vendor-base.9c08bbd0.js'; | ||
import 'node:path'; | ||
import 'node:module'; | ||
import 'vite-node/constants'; | ||
@@ -92,2 +98,4 @@ import 'node:stream'; | ||
context.console = createCustomConsole(state); | ||
context.setImmediate = setImmediate; | ||
context.clearImmediate = clearImmediate; | ||
if (ctx.invalidates) { | ||
@@ -94,0 +102,0 @@ ctx.invalidates.forEach((fsPath) => { |
@@ -5,4 +5,4 @@ import { performance } from 'node:perf_hooks'; | ||
import { g as getWorkerState } from './vendor-global.97e4527c.js'; | ||
import { l as loadEnvironment } from './vendor-environments.443ecd82.js'; | ||
import { s as startViteNode, m as moduleCache, a as mockMap } from './vendor-execute.9ab1c1a7.js'; | ||
import { l as loadEnvironment } from './vendor-environments.37f266a9.js'; | ||
import { s as startViteNode, m as moduleCache, a as mockMap } from './vendor-execute.4fc8203a.js'; | ||
import { s as setupInspect } from './vendor-inspector.47fc8cbb.js'; | ||
@@ -12,4 +12,13 @@ import { r as rpcDone, c as createSafeRpc } from './vendor-rpc.cbd8e972.js'; | ||
import 'pathe'; | ||
import './vendor-index.0b5b3600.js'; | ||
import 'acorn'; | ||
import 'node:module'; | ||
import 'node:fs'; | ||
import 'node:assert'; | ||
import 'node:process'; | ||
import 'node:path'; | ||
import 'node:v8'; | ||
import 'node:util'; | ||
import 'node:console'; | ||
import 'local-pkg'; | ||
import 'node:console'; | ||
import 'node:vm'; | ||
@@ -20,7 +29,4 @@ import 'vite-node/client'; | ||
import './vendor-paths.84fc7a99.js'; | ||
import 'node:fs'; | ||
import '@vitest/utils'; | ||
import './vendor-base.9c08bbd0.js'; | ||
import 'node:path'; | ||
import 'node:module'; | ||
import 'vite-node/constants'; | ||
@@ -27,0 +33,0 @@ |
{ | ||
"name": "vitest", | ||
"type": "module", | ||
"version": "0.34.1", | ||
"version": "0.34.2", | ||
"description": "A blazing fast unit test framework powered by Vite", | ||
@@ -154,8 +154,8 @@ "author": "Anthony Fu <anthonyfu117@hotmail.com>", | ||
"why-is-node-running": "^2.2.2", | ||
"@vitest/utils": "0.34.1", | ||
"vite-node": "0.34.1", | ||
"@vitest/runner": "0.34.1", | ||
"@vitest/expect": "0.34.1", | ||
"@vitest/snapshot": "0.34.1", | ||
"@vitest/spy": "0.34.1" | ||
"@vitest/runner": "0.34.2", | ||
"@vitest/utils": "0.34.2", | ||
"vite-node": "0.34.2", | ||
"@vitest/expect": "0.34.2", | ||
"@vitest/spy": "0.34.2", | ||
"@vitest/snapshot": "0.34.2" | ||
}, | ||
@@ -162,0 +162,0 @@ "devDependencies": { |
Sorry, the diff of this file is too big to display
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
1405347
77
38094
68
+ Added@vitest/expect@0.34.2(transitive)
+ Added@vitest/runner@0.34.2(transitive)
+ Added@vitest/snapshot@0.34.2(transitive)
+ Added@vitest/spy@0.34.2(transitive)
+ Added@vitest/utils@0.34.2(transitive)
+ Addedvite-node@0.34.2(transitive)
- Removed@vitest/expect@0.34.1(transitive)
- Removed@vitest/runner@0.34.1(transitive)
- Removed@vitest/snapshot@0.34.1(transitive)
- Removed@vitest/spy@0.34.1(transitive)
- Removed@vitest/utils@0.34.1(transitive)
- Removedvite-node@0.34.1(transitive)
Updated@vitest/expect@0.34.2
Updated@vitest/runner@0.34.2
Updated@vitest/snapshot@0.34.2
Updated@vitest/spy@0.34.2
Updated@vitest/utils@0.34.2
Updatedvite-node@0.34.2