diff --git a/docs/advanced/runner.md b/docs/advanced/runner.md index 5d45c023e21d..734b279d9042 100644 --- a/docs/advanced/runner.md +++ b/docs/advanced/runner.md @@ -77,7 +77,7 @@ export interface VitestRunner { */ importFile(filepath: string, source: VitestRunnerImportSource): unknown /** - * Publically available configuration. + * Publicly available configuration. */ config: VitestRunnerConfig } @@ -117,7 +117,7 @@ export const myCustomTask = function (name, fn) { import { afterAll, beforeAll, describe, myCustomTask } from '../utils/custom.js' import { gardener } from './gardener.js' -deccribe('take care of the garden', () => { +describe('take care of the garden', () => { beforeAll(() => { gardener.putWorkingClothes() }) @@ -136,7 +136,7 @@ deccribe('take care of the garden', () => { ``` ```bash -vitest ./garder/tasks.test.js +vitest ./garden/tasks.test.js ``` ::: warning diff --git a/docs/api/expect-typeof.md b/docs/api/expect-typeof.md index c73ec85a518c..7aa7742135ce 100644 --- a/docs/api/expect-typeof.md +++ b/docs/api/expect-typeof.md @@ -301,7 +301,7 @@ - **Type:** `() => void` - This matcher checks, if provided type is a `functon`. + This matcher checks, if provided type is a `function`. ```ts import { expectTypeOf } from 'vitest' diff --git a/docs/api/vi.md b/docs/api/vi.md index 82a561326759..aa42e501f4e7 100644 --- a/docs/api/vi.md +++ b/docs/api/vi.md @@ -305,12 +305,12 @@ test('importing the next module imports mocked one', () => { test('change state', async () => { const mod = await import('./some/path') mod.changeLocalState('new value') - expect(mod.getlocalState()).toBe('new value') + expect(mod.getLocalState()).toBe('new value') }) test('module has old state', async () => { const mod = await import('./some/path') - expect(mod.getlocalState()).toBe('old value') + expect(mod.getLocalState()).toBe('old value') }) ``` @@ -402,7 +402,7 @@ import.meta.env.NODE_ENV === 'development' ```ts import { vi } from 'vitest' -// `innerWidth` is "0" before callling stubGlobal +// `innerWidth` is "0" before calling stubGlobal vi.stubGlobal('innerWidth', 100) @@ -456,7 +456,7 @@ IntersectionObserver === undefined - **Type:** `() => Vitest` - Calls every microtask that was queued by `proccess.nextTick`. This will also run all microtasks scheduled by themselves. + Calls every microtask that was queued by `process.nextTick`. This will also run all microtasks scheduled by themselves. ## vi.runAllTimers diff --git a/docs/config/index.md b/docs/config/index.md index 3ec0e35eacf9..7ee772b95fb9 100644 --- a/docs/config/index.md +++ b/docs/config/index.md @@ -644,7 +644,7 @@ Use `provider` to select the tool for coverage collection. - **Available for providers:** `'c8' | 'istanbul'` - **CLI:** `--coverage.enabled`, `--coverage.enabled=false` -Enables coverage collection. Can be overriden using `--coverage` CLI option. +Enables coverage collection. Can be overridden using `--coverage` CLI option. #### include @@ -1157,7 +1157,7 @@ Options for configuring [typechecking](/guide/testing-types) test environment. What tools to use for type checking. Vitest will spawn a process with certain parameters for easier parsing, depending on the type. Checker should implement the same output format as `tsc`. -You need to have a package installed to use typecheker: +You need to have a package installed to use typechecker: - `tsc` requires `typescript` package - `vue-tsc` requires `vue-tsc` package diff --git a/docs/guide/environment.md b/docs/guide/environment.md index f60cce33c766..dfd365fa0316 100644 --- a/docs/guide/environment.md +++ b/docs/guide/environment.md @@ -64,7 +64,7 @@ interface PopulateOptions { interface PopulateResult { // a list of all keys that were copied, even if value doesn't exist on original object keys: Set - // a map of original object that might have been overriden with keys + // a map of original object that might have been overridden with keys // you can return these values inside `teardown` function originals: Map } diff --git a/docs/guide/mocking.md b/docs/guide/mocking.md index e483e55402cb..d6ca65788152 100644 --- a/docs/guide/mocking.md +++ b/docs/guide/mocking.md @@ -324,7 +324,7 @@ There is much more to MSW. You can access cookies and query parameters, define m Whenever we test code that involves timeouts or intervals, instead of having our tests wait it out or timeout. We can speed up our tests by using "fake" timers by mocking calls to `setTimeout` and `setInterval`, too. -See the [`vi.usefaketimers` api section](/api/#vi-usefaketimers) for a more in depth detailed API description. +See the [`vi.useFakeTimers` api section](/api/#vi-usefaketimers) for a more in depth detailed API description. ### Example @@ -486,7 +486,7 @@ vi.mock('some-path', () => { method: vi.fn(), } } - // now everytime useObject() is called it will + // now every time that useObject() is called it will // return the same object reference return _cache } diff --git a/packages/runner/src/types/runner.ts b/packages/runner/src/types/runner.ts index 35c228204d9c..2892ff6b79ad 100644 --- a/packages/runner/src/types/runner.ts +++ b/packages/runner/src/types/runner.ts @@ -93,7 +93,7 @@ export interface VitestRunner { */ importFile(filepath: string, source: VitestRunnerImportSource): unknown /** - * Publically available configuration. + * Publicly available configuration. */ config: VitestRunnerConfig } diff --git a/packages/vitest/src/defaults.ts b/packages/vitest/src/defaults.ts index d5210544c89a..6d6ec909d483 100644 --- a/packages/vitest/src/defaults.ts +++ b/packages/vitest/src/defaults.ts @@ -25,7 +25,7 @@ const defaultCoverageExcludes = [ '**/.{eslint,mocha,prettier}rc.{js,cjs,yml}', ] -// These are the generic defaults for coverage. Providers may also set some provider speficic defaults. +// These are the generic defaults for coverage. Providers may also set some provider specific defaults. export const coverageConfigDefaults: ResolvedCoverageOptions = { provider: 'c8', enabled: false, diff --git a/packages/vitest/src/integrations/snapshot/env.ts b/packages/vitest/src/integrations/snapshot/env.ts index 518a3dfb2cf8..50d3680e2d22 100644 --- a/packages/vitest/src/integrations/snapshot/env.ts +++ b/packages/vitest/src/integrations/snapshot/env.ts @@ -12,7 +12,7 @@ export function setupSnapshotEnvironment(environment: SnapshotEnvironment) { _snapshotEnvironment = environment } -export function getSnapshotEnironment() { +export function getSnapshotEnvironment() { if (!_snapshotEnvironment) throw new Error('Snapshot environment is not setup') return _snapshotEnvironment diff --git a/packages/vitest/src/integrations/snapshot/port/inlineSnapshot.ts b/packages/vitest/src/integrations/snapshot/port/inlineSnapshot.ts index c19fde2a590b..dada3be04883 100644 --- a/packages/vitest/src/integrations/snapshot/port/inlineSnapshot.ts +++ b/packages/vitest/src/integrations/snapshot/port/inlineSnapshot.ts @@ -1,7 +1,7 @@ import type MagicString from 'magic-string' import { lineSplitRE, offsetToLineNumber, positionToOffset } from '../../../utils/source-map' import { getCallLastIndex } from '../../../utils' -import { getSnapshotEnironment } from '../env' +import { getSnapshotEnvironment } from '../env' export interface InlineSnapshot { snapshot: string @@ -13,7 +13,7 @@ export interface InlineSnapshot { export async function saveInlineSnapshots( snapshots: Array, ) { - const environment = getSnapshotEnironment() + const environment = getSnapshotEnvironment() const MagicString = (await import('magic-string')).default const files = new Set(snapshots.map(i => i.file)) await Promise.all(Array.from(files).map(async (file) => { diff --git a/packages/vitest/src/integrations/snapshot/port/state.ts b/packages/vitest/src/integrations/snapshot/port/state.ts index de7ad8c84143..5ac6419205a2 100644 --- a/packages/vitest/src/integrations/snapshot/port/state.ts +++ b/packages/vitest/src/integrations/snapshot/port/state.ts @@ -10,7 +10,7 @@ import type { ParsedStack, SnapshotData, SnapshotMatchOptions, SnapshotResult, S import { slash } from '../../../utils' import { parseStacktrace } from '../../../utils/source-map' import type { SnapshotEnvironment } from '../env' -import { getSnapshotEnironment } from '../env' +import { getSnapshotEnvironment } from '../env' import type { InlineSnapshot } from './inlineSnapshot' import { saveInlineSnapshots } from './inlineSnapshot' @@ -83,14 +83,14 @@ export default class SnapshotState { printBasicPrototype: false, ...options.snapshotFormat, } - this._environment = getSnapshotEnironment() + this._environment = getSnapshotEnvironment() } static async create( testFilePath: string, options: SnapshotStateOptions, ) { - const environment = getSnapshotEnironment() + const environment = getSnapshotEnvironment() const snapshotPath = await environment.resolvePath(testFilePath) const content = await environment.readSnapshotFile(snapshotPath) return new SnapshotState(testFilePath, snapshotPath, content, options) diff --git a/packages/vitest/src/integrations/snapshot/port/utils.ts b/packages/vitest/src/integrations/snapshot/port/utils.ts index d4c828727202..eb1b2ad2603e 100644 --- a/packages/vitest/src/integrations/snapshot/port/utils.ts +++ b/packages/vitest/src/integrations/snapshot/port/utils.ts @@ -13,7 +13,7 @@ import { } from 'pretty-format' import type { SnapshotData, SnapshotStateOptions } from '../../../types' import { isObject } from '../../../utils' -import { getSnapshotEnironment } from '../env' +import { getSnapshotEnvironment } from '../env' import { getSerializers } from './plugins' // TODO: rewrite and clean up @@ -133,7 +133,7 @@ function printBacktickString(str: string): string { export async function ensureDirectoryExists(filePath: string) { try { - const environment = getSnapshotEnironment() + const environment = getSnapshotEnvironment() await environment.prepareDirectory(join(dirname(filePath))) } catch { } @@ -147,7 +147,7 @@ export async function saveSnapshotFile( snapshotData: SnapshotData, snapshotPath: string, ) { - const environment = getSnapshotEnironment() + const environment = getSnapshotEnvironment() const snapshots = Object.keys(snapshotData) .sort(naturalCompare) .map( diff --git a/packages/vitest/src/integrations/vi.ts b/packages/vitest/src/integrations/vi.ts index d67a481b8c0e..93c1db0c57d7 100644 --- a/packages/vitest/src/integrations/vi.ts +++ b/packages/vitest/src/integrations/vi.ts @@ -294,7 +294,7 @@ class VitestUtils { } /** - * Reset enviromental variables to the ones that were available before first `vi.stubEnv` was called. + * Reset environmental variables to the ones that were available before first `vi.stubEnv` was called. */ public unstubAllEnvs() { this._stubsEnv.forEach((original, name) => { diff --git a/packages/vitest/src/node/reporters/base.ts b/packages/vitest/src/node/reporters/base.ts index a52d6666a80a..035b9dd192ab 100644 --- a/packages/vitest/src/node/reporters/base.ts +++ b/packages/vitest/src/node/reporters/base.ts @@ -289,12 +289,12 @@ export abstract class BaseReporter implements Reporter { async reportBenchmarkSummary(files: File[]) { const logger = this.ctx.logger - const benchs = getTests(files) + const benches = getTests(files) - const topBenchs = benchs.filter(i => i.result?.benchmark?.rank === 1) + const topBenches = benches.filter(i => i.result?.benchmark?.rank === 1) logger.log(`\n${c.cyan(c.inverse(c.bold(' BENCH ')))} ${c.cyan('Summary')}\n`) - for (const bench of topBenchs) { + for (const bench of topBenches) { const group = bench.suite if (!group) continue diff --git a/packages/vitest/src/node/reporters/benchmark/table/tableRender.ts b/packages/vitest/src/node/reporters/benchmark/table/tableRender.ts index ae251fe3d874..4a2c825a9613 100644 --- a/packages/vitest/src/node/reporters/benchmark/table/tableRender.ts +++ b/packages/vitest/src/node/reporters/benchmark/table/tableRender.ts @@ -37,10 +37,10 @@ function formatNumber(number: number) { const tableHead = ['name', 'hz', 'min', 'max', 'mean', 'p75', 'p99', 'p995', 'p999', 'rme', 'samples'] function renderTableHead(tasks: Task[]) { - const benchs = tasks + const benches = tasks .map(i => i.meta?.benchmark ? i.result?.benchmark : undefined) .filter(notNullish) - const allItems = benchs.map(renderBenchmarkItems).concat([tableHead]) + const allItems = benches.map(renderBenchmarkItems).concat([tableHead]) return `${' '.repeat(3)}${tableHead.map((i, idx) => { const width = Math.max(...allItems.map(i => i[idx].length)) return idx @@ -69,10 +69,10 @@ function renderBenchmark(task: Benchmark, tasks: Task[]): string { if (!result) return task.name - const benchs = tasks + const benches = tasks .map(i => i.meta?.benchmark ? i.result?.benchmark : undefined) .filter(notNullish) - const allItems = benchs.map(renderBenchmarkItems).concat([tableHead]) + const allItems = benches.map(renderBenchmarkItems).concat([tableHead]) const items = renderBenchmarkItems(result) const padded = items.map((i, idx) => { const width = Math.max(...allItems.map(i => i[idx].length)) @@ -95,7 +95,7 @@ function renderBenchmark(task: Benchmark, tasks: Task[]): string { c.dim(padded[10]), // sample result.rank === 1 ? c.bold(c.green(' fastest')) - : result.rank === benchs.length && benchs.length > 2 + : result.rank === benches.length && benches.length > 2 ? c.bold(c.gray(' slowest')) : '', ].join(' ') diff --git a/packages/vitest/src/node/reporters/renderers/listRenderer.ts b/packages/vitest/src/node/reporters/renderers/listRenderer.ts index 8f9b9afcc2d6..5e9ca09c057f 100644 --- a/packages/vitest/src/node/reporters/renderers/listRenderer.ts +++ b/packages/vitest/src/node/reporters/renderers/listRenderer.ts @@ -58,11 +58,11 @@ function renderBenchmark(task: Benchmark, tasks: Task[]): string { if (!result) return task.name - const benchs = tasks + const benches = tasks .map(i => i.meta?.benchmark ? i.result?.benchmark : undefined) .filter(notNullish) - const allItems = benchs.map(renderBenchmarkItems) + const allItems = benches.map(renderBenchmarkItems) const items = renderBenchmarkItems(result) const padded = items.map((i, idx) => { const width = Math.max(...allItems.map(i => i[idx].length)) @@ -80,7 +80,7 @@ function renderBenchmark(task: Benchmark, tasks: Task[]): string { c.dim(` (${padded[4]} samples)`), result.rank === 1 ? c.bold(c.green(' fastest')) - : result.rank === benchs.length && benchs.length > 2 + : result.rank === benches.length && benches.length > 2 ? c.bold(c.gray(' slowest')) : '', ].join('') diff --git a/packages/vitest/src/runtime/loader.ts b/packages/vitest/src/runtime/loader.ts index 1191a3ce42d1..421b951a6a3d 100644 --- a/packages/vitest/src/runtime/loader.ts +++ b/packages/vitest/src/runtime/loader.ts @@ -38,7 +38,7 @@ const detectESM = (url: string, source: string | null) => { } // apply transformations only to libraries -// inline code proccessed by vite-node +// inline code processed by vite-node // make Node pseudo ESM export const resolve: Resolver = async (url, context, next) => { const { parentURL } = context diff --git a/packages/vitest/src/typecheck/typechecker.ts b/packages/vitest/src/typecheck/typechecker.ts index 20d68fec0973..29b08d12cf4c 100644 --- a/packages/vitest/src/typecheck/typechecker.ts +++ b/packages/vitest/src/typecheck/typechecker.ts @@ -244,7 +244,7 @@ export class Typechecker { this._onWatcherRerun?.() this._result.sourceErrors = [] this._result.files = [] - this._tests = null // test structure migh've changed + this._tests = null // test structure might've changed rerunTriggered = true } if (/Found \w+ errors*. Watching for/.test(output)) { diff --git a/packages/vitest/src/types/coverage.ts b/packages/vitest/src/types/coverage.ts index 209f274ec9e1..db15d9fd3811 100644 --- a/packages/vitest/src/types/coverage.ts +++ b/packages/vitest/src/types/coverage.ts @@ -80,7 +80,7 @@ export type ResolvedCoverageOptions = export interface BaseCoverageOptions { /** - * Enables coverage collection. Can be overriden using `--coverage` CLI option. + * Enables coverage collection. Can be overridden using `--coverage` CLI option. * * @default false */ diff --git a/packages/web-worker/src/utils.ts b/packages/web-worker/src/utils.ts index 5209412aed48..1ed47dd90b53 100644 --- a/packages/web-worker/src/utils.ts +++ b/packages/web-worker/src/utils.ts @@ -30,7 +30,7 @@ function createClonedMessageEvent(data: any, transferOrOptions: StructuredSerial }) } if (clone !== 'none') { - debug('create message event, using polifylled structured clone') + debug('create message event, using polyfilled structured clone') transfer?.length && console.warn( '[@vitest/web-worker] `structuredClone` is not supported in this environment. ' + 'Falling back to polyfill, your transferable options will be lost. ' diff --git a/test/core/test/imports.test.ts b/test/core/test/imports.test.ts index 874f236b0c30..83af8458beac 100644 --- a/test/core/test/imports.test.ts +++ b/test/core/test/imports.test.ts @@ -37,7 +37,7 @@ test('dynamic absolute from root import works', async () => { expect(stringTimeoutMod).toBe(variableTimeoutMod) }) -test('dynamic absolute with extension mport works', async () => { +test('dynamic absolute with extension import works', async () => { const stringTimeoutMod = await import('./../src/timeout') const timeoutPath = '/src/timeout.ts' diff --git a/test/core/test/serialize.test.ts b/test/core/test/serialize.test.ts index 325d9add9a6f..c54b5af84f19 100644 --- a/test/core/test/serialize.test.ts +++ b/test/core/test/serialize.test.ts @@ -110,14 +110,14 @@ describe('error serialize', () => { Object.defineProperty(error, 'array', { value: [{ get name() { - throw new Error('name cannnot be accessed') + throw new Error('name cannot be accessed') }, }], }) expect(serializeError(error)).toEqual({ array: [ { - name: ': name cannnot be accessed', + name: ': name cannot be accessed', }, ], constructor: 'Function', diff --git a/test/core/test/stubs.test.ts b/test/core/test/stubs.test.ts index d3a00164ec38..9ee8c3a96669 100644 --- a/test/core/test/stubs.test.ts +++ b/test/core/test/stubs.test.ts @@ -17,7 +17,7 @@ describe('stubbing globals', () => { vi.unstubAllGlobals() }) - it('overrites setter', () => { + it('overwrites setter', () => { const descriptor = { get: () => 'getter', set: () => {}, diff --git a/test/snapshots/tools/generate-inline-test.mjs b/test/snapshots/tools/generate-inline-test.mjs index e72c75dccc63..d376ced13a6f 100644 --- a/test/snapshots/tools/generate-inline-test.mjs +++ b/test/snapshots/tools/generate-inline-test.mjs @@ -4,10 +4,10 @@ import { dirname, resolve } from 'pathe' const dir = dirname(fileURLToPath(import.meta.url)) -export async function generateInlineTest(templatePath, testpath) { +export async function generateInlineTest(templatePath, testPath) { const template = await fs.readFile(templatePath, 'utf8') - await fs.writeFile(testpath, template) - console.log(`Generated ${testpath}`) + await fs.writeFile(testPath, template) + console.log(`Generated ${testPath}`) } const filepath = resolve(dir, '../test-update/snapshots-inline-js.test.js') diff --git a/test/web-worker/test/postMessage.test.ts b/test/web-worker/test/postMessage.test.ts index a4b082009012..4f35ee6a3076 100644 --- a/test/web-worker/test/postMessage.test.ts +++ b/test/web-worker/test/postMessage.test.ts @@ -1,7 +1,7 @@ import { expect, it } from 'vitest' import MyWorker from '../src/worker?worker' -it('throws syntax errorm if no arguments are provided', () => { +it('throws syntax error if no arguments are provided', () => { const worker = new MyWorker() // @ts-expect-error requires at least one argument