docs: fix typos (#2815)

This commit is contained in:
Lioness100 2023-02-08 02:30:35 -08:00 committed by GitHub
parent ab5f892706
commit 2f87505ffd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 48 additions and 48 deletions

View File

@ -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

View File

@ -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'

View File

@ -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

View File

@ -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

View File

@ -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<string>
// 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<string | symbol, any>
}

View File

@ -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
}

View File

@ -93,7 +93,7 @@ export interface VitestRunner {
*/
importFile(filepath: string, source: VitestRunnerImportSource): unknown
/**
* Publically available configuration.
* Publicly available configuration.
*/
config: VitestRunnerConfig
}

View File

@ -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,

View File

@ -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

View File

@ -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<InlineSnapshot>,
) {
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) => {

View File

@ -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)

View File

@ -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(

View File

@ -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) => {

View File

@ -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

View File

@ -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(' ')

View File

@ -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('')

View File

@ -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

View File

@ -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)) {

View File

@ -80,7 +80,7 @@ export type ResolvedCoverageOptions<T extends Provider = Provider> =
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
*/

View File

@ -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. '

View File

@ -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'

View File

@ -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: '<unserializable>: name cannnot be accessed',
name: '<unserializable>: name cannot be accessed',
},
],
constructor: 'Function<Error>',

View File

@ -17,7 +17,7 @@ describe('stubbing globals', () => {
vi.unstubAllGlobals()
})
it('overrites setter', () => {
it('overwrites setter', () => {
const descriptor = {
get: () => 'getter',
set: () => {},

View File

@ -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')

View File

@ -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