mirror of
https://github.com/vitest-dev/vitest.git
synced 2025-12-08 18:26:03 +00:00
chore: fix various typos (#7663)
This commit is contained in:
parent
29f5a848f7
commit
3fdee3da8b
@ -52,7 +52,7 @@ function onInit(vitest: Vitest): Awaitable<void>
|
||||
This method is called when [Vitest](/advanced/api/vitest) was initiated or started, but before the tests were filtered.
|
||||
|
||||
::: info
|
||||
Internally this method is called inside [`vitest.start`](/advanced/api/vitest#start), [`vitest.init`](/advanced/api/vitest#init) or [`vitest.mergeReports`](/advanced/api/vitest#mergereports). If you are using programmatic API, make sure to call either one dependning on your needs before calling [`vitest.runTestSpecifications`](/advanced/api/vitest#runtestspecifications), for example. Built-in CLI will always run methods in correct order.
|
||||
Internally this method is called inside [`vitest.start`](/advanced/api/vitest#start), [`vitest.init`](/advanced/api/vitest#init) or [`vitest.mergeReports`](/advanced/api/vitest#mergereports). If you are using programmatic API, make sure to call either one depending on your needs before calling [`vitest.runTestSpecifications`](/advanced/api/vitest#runtestspecifications), for example. Built-in CLI will always run methods in correct order.
|
||||
:::
|
||||
|
||||
Note that you can also get access to `vitest` instance from test cases, suites and test modules via a [`project`](/advanced/api/test-project) property, but it might also be useful to store a reference to `vitest` in this method.
|
||||
@ -139,7 +139,7 @@ The third argument indicated why the test run was finished:
|
||||
|
||||
- `passed`: test run was finished normally and there are no errors
|
||||
- `failed`: test run has at least one error (due to a syntax error during collection or an actual error during test execution)
|
||||
- `interrupted`: test was interruped by [`vitest.cancelCurrentRun`](/advanced/api/vitest#cancelcurrentrun) call or `Ctrl+C` was pressed in the terminal (note that it's still possible to have failed tests in this case)
|
||||
- `interrupted`: test was interrupted by [`vitest.cancelCurrentRun`](/advanced/api/vitest#cancelcurrentrun) call or `Ctrl+C` was pressed in the terminal (note that it's still possible to have failed tests in this case)
|
||||
|
||||
If Vitest didn't find any test files to run, this event will be invoked with empty arrays of modules and errors, and the state will depend on the value of [`config.passWithNoTests`](/config/#passwithnotests).
|
||||
|
||||
|
||||
@ -124,7 +124,7 @@ const value = inject('key')
|
||||
```
|
||||
:::
|
||||
|
||||
The values can be provided dynamicaly. Provided value in tests will be updated on their next run.
|
||||
The values can be provided dynamically. Provided value in tests will be updated on their next run.
|
||||
|
||||
::: tip
|
||||
This method is also available to [global setup files](/config/#globalsetup) for cases where you cannot use the public API:
|
||||
|
||||
@ -33,7 +33,7 @@ The ID of the module in Vite's module graph. Usually, it's an absolute file path
|
||||
|
||||
## testModule
|
||||
|
||||
Instance of [`TestModule`](/advanced/api/test-module) assosiated with the specification. If test wasn't queued yet, this will be `undefined`.
|
||||
Instance of [`TestModule`](/advanced/api/test-module) associated with the specification. If test wasn't queued yet, this will be `undefined`.
|
||||
|
||||
## pool <Badge type="warning">experimental</Badge> {#pool}
|
||||
|
||||
|
||||
@ -93,7 +93,7 @@ In the future, the old API won't be exposed anymore.
|
||||
|
||||
The global snapshot manager. Vitest keeps track of all snapshots using the `snapshot.add` method.
|
||||
|
||||
You can get the latest summary of snapshots via the `vitest.snapshot.summay` property.
|
||||
You can get the latest summary of snapshots via the `vitest.snapshot.summary` property.
|
||||
|
||||
## cache
|
||||
|
||||
@ -130,7 +130,7 @@ function provide<T extends keyof ProvidedContext & string>(
|
||||
|
||||
Vitest exposes `provide` method which is a shorthand for `vitest.getRootProject().provide`. With this method you can pass down values from the main thread to tests. All values are checked with `structuredClone` before they are stored, but the values themselves are not cloned.
|
||||
|
||||
To recieve the values in the test, you need to import `inject` method from `vitest` entrypont:
|
||||
To receive the values in the test, you need to import `inject` method from `vitest` entrypoint:
|
||||
|
||||
```ts
|
||||
import { inject } from 'vitest'
|
||||
@ -172,7 +172,7 @@ This returns the root context object. This is a shorthand for `vitest.getRootPro
|
||||
function getProjectByName(name: string): TestProject
|
||||
```
|
||||
|
||||
This method returns the project by its name. Simillar to calling `vitest.projects.find`.
|
||||
This method returns the project by its name. Similar to calling `vitest.projects.find`.
|
||||
|
||||
::: warning
|
||||
In case the project doesn't exist, this method will return the root project - make sure to check the names again if the project you are looking for is the one returned.
|
||||
@ -297,7 +297,7 @@ As of Vitest 3, this method uses a cache to check if the file is a test. To make
|
||||
function clearSpecificationsCache(moduleId?: string): void
|
||||
```
|
||||
|
||||
Vitest automatically caches test specifications for each file when [`globTestSpecifications`](#globtestspecifications) or [`runTestSpecifications`](#runtestspecifications) is called. This method clears the cache for the given file or the whole cache alltogether depending on the first argument.
|
||||
Vitest automatically caches test specifications for each file when [`globTestSpecifications`](#globtestspecifications) or [`runTestSpecifications`](#runtestspecifications) is called. This method clears the cache for the given file or the whole cache altogether depending on the first argument.
|
||||
|
||||
## runTestSpecifications
|
||||
|
||||
@ -452,7 +452,7 @@ function exit(force = false): Promise<void>
|
||||
|
||||
Closes all projects and exit the process. If `force` is set to `true`, the process will exit immediately after closing the projects.
|
||||
|
||||
This method will also forcefuly call `process.exit()` if the process is still active after [`config.teardownTimeout`](/config/#teardowntimeout) milliseconds.
|
||||
This method will also forcefully call `process.exit()` if the process is still active after [`config.teardownTimeout`](/config/#teardowntimeout) milliseconds.
|
||||
|
||||
## shouldKeepServer
|
||||
|
||||
|
||||
@ -71,7 +71,7 @@ finally {
|
||||
}
|
||||
```
|
||||
|
||||
If you intend to keep the `Vitest` instance, make sure to at least call [`init`](/advanced/api/vitest#init). This will initialise reporters and the coverage provider, but won't run any tests. It is also recommended to enable the `watch` mode even if you don't intend to use the Vitest watcher, but want to keep the instance running. Vitest relies on this flag for some of its features to work correctly in a continous process.
|
||||
If you intend to keep the `Vitest` instance, make sure to at least call [`init`](/advanced/api/vitest#init). This will initialise reporters and the coverage provider, but won't run any tests. It is also recommended to enable the `watch` mode even if you don't intend to use the Vitest watcher, but want to keep the instance running. Vitest relies on this flag for some of its features to work correctly in a continuous process.
|
||||
|
||||
After reporters are initialised, use [`runTestSpecifications`](/advanced/api/vitest#runtestspecifications) or [`rerunTestSpecifications`](/advanced/api/vitest#reruntestspecifications) to run tests if manual run is required:
|
||||
|
||||
@ -88,7 +88,7 @@ watcher.on('change', async (file) => {
|
||||
```
|
||||
|
||||
::: warning
|
||||
The example above shows a potential usecase if you disable the default watcher behaviour. By default, Vitest already reruns tests if files change.
|
||||
The example above shows a potential use-case if you disable the default watcher behaviour. By default, Vitest already reruns tests if files change.
|
||||
|
||||
Also note that `getModuleSpecifications` will not resolve test files unless they were already processed by `globTestSpecifications`. If the file was just created, use `project.matchesGlobPattern` instead:
|
||||
|
||||
|
||||
@ -381,7 +381,7 @@ It is recommended to use this only after the other locators don't work for your
|
||||
|
||||
- `exact: boolean`
|
||||
|
||||
Whether the `text` is matched exactly: case-sensetive and whole-string. Disabled by default. This option is ignored if `text` is a regular expression. Note that exact match still trims whitespace.
|
||||
Whether the `text` is matched exactly: case-sensitive and whole-string. Disabled by default. This option is ignored if `text` is a regular expression. Note that exact match still trims whitespace.
|
||||
|
||||
#### See also
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
Since Vitest 3, you can specify several different browser setups using the new [`browser.instances`](/guide/browser/config#browser-instances) option.
|
||||
|
||||
The main advatage of using the `browser.instances` over the [workspace](/guide/workspace) is improved caching. Every project will use the same Vite server meaning the file transform and [dependency pre-bundling](https://vite.dev/guide/dep-pre-bundling.html) has to happen only once.
|
||||
The main advantage of using the `browser.instances` over the [workspace](/guide/workspace) is improved caching. Every project will use the same Vite server meaning the file transform and [dependency pre-bundling](https://vite.dev/guide/dep-pre-bundling.html) has to happen only once.
|
||||
|
||||
## Several Browsers
|
||||
|
||||
@ -128,7 +128,7 @@ start tests with --browser=name or --project=name flag. › - Use arrow-keys. Re
|
||||
firefox
|
||||
```
|
||||
|
||||
If you have several non-headless projects in CI (i.e. the `headless: false` is set manually in the config and not overriden in CI env), Vitest will fail the run and won't start any tests.
|
||||
If you have several non-headless projects in CI (i.e. the `headless: false` is set manually in the config and not overridden in CI env), Vitest will fail the run and won't start any tests.
|
||||
|
||||
The ability to run tests in headless mode is not affected by this. You can still run all instances in parallel as long as they don't have `headless: false`.
|
||||
:::
|
||||
|
||||
@ -74,7 +74,7 @@ Note that the context is created for every _test file_, not every _test_ like in
|
||||
:::
|
||||
|
||||
::: warning
|
||||
Vitest awlays sets `ignoreHTTPSErrors` to `true` in case your server is served via HTTPS and `serviceWorkers` to `'allow'` to support module mocking via [MSW](https://mswjs.io).
|
||||
Vitest always sets `ignoreHTTPSErrors` to `true` in case your server is served via HTTPS and `serviceWorkers` to `'allow'` to support module mocking via [MSW](https://mswjs.io).
|
||||
|
||||
It is also recommended to use [`test.browser.viewport`](/guide/browser/config#browser-headless) instead of specifying it here as it will be lost when tests are running in headless mode.
|
||||
:::
|
||||
|
||||
@ -578,7 +578,7 @@ export const JestChaiExpect: ChaiPlugin = (chai, utils) => {
|
||||
})
|
||||
|
||||
// manually compare array elements since `jestEquals` cannot
|
||||
// apply assymetric matcher to `undefined` array element.
|
||||
// apply asymmetric matcher to `undefined` array element.
|
||||
function equalsArgumentArray(a: unknown[], b: unknown[]) {
|
||||
return a.length === b.length && a.every((aItem, i) =>
|
||||
jestEquals(aItem, b[i], [...customTesters, iterableEquality]),
|
||||
|
||||
@ -5,7 +5,7 @@ import crypto from 'node:crypto'
|
||||
export function isValidApiRequest(config: ResolvedConfig, req: IncomingMessage): boolean {
|
||||
const url = new URL(req.url ?? '', 'http://localhost')
|
||||
|
||||
// validate token. token is injected in ui/tester/orchestrator html, which is cross origin proteced.
|
||||
// validate token. token is injected in ui/tester/orchestrator html, which is cross origin protected.
|
||||
try {
|
||||
const token = url.searchParams.get('token')
|
||||
if (token && crypto.timingSafeEqual(
|
||||
|
||||
@ -20,9 +20,9 @@ export class FakeTimers {
|
||||
// | _fakingTime | _fakingDate |
|
||||
// +-------------+-------------+
|
||||
// | false | falsy | initial
|
||||
// | false | truethy | vi.setSystemTime called first (for mocking only Date without fake timers)
|
||||
// | false | truthy | vi.setSystemTime called first (for mocking only Date without fake timers)
|
||||
// | true | falsy | vi.useFakeTimers called first
|
||||
// | true | truethy | unreachable
|
||||
// | true | truthy | unreachable
|
||||
private _fakingTime: boolean
|
||||
private _fakingDate: Date | null
|
||||
private _fakeTimers: FakeTimerWithContext
|
||||
|
||||
@ -248,7 +248,7 @@ export class SummaryReporter implements Reporter {
|
||||
}
|
||||
else {
|
||||
// Run is about to end as there are less tests left than whole run had parallel at max.
|
||||
// Remove finished test immediatelly.
|
||||
// Remove finished test immediately.
|
||||
this.removeTestModule(module.id)
|
||||
}
|
||||
|
||||
|
||||
@ -55,7 +55,7 @@ export class VitestSpecifications {
|
||||
f => ({ ...f, filename: resolve(dir, f.filename) }),
|
||||
))
|
||||
|
||||
// Key is file and val sepcifies whether we have matched this file with testLocation
|
||||
// Key is file and val specifies whether we have matched this file with testLocation
|
||||
const testLocHasMatch: { [f: string]: boolean } = {}
|
||||
|
||||
await Promise.all(this.vitest.projects.map(async (project) => {
|
||||
|
||||
@ -216,7 +216,7 @@ export async function resolveBrowserWorkspace(
|
||||
|
||||
if (project.config.browser.providerOptions) {
|
||||
vitest.logger.warn(
|
||||
withLabel('yellow', 'Vitest', `"providerOptions"${originalName ? ` in "${originalName}" project` : ''} is ignored because it's overriden by the configs. To hide this warning, remove the "providerOptions" property from the browser configuration.`),
|
||||
withLabel('yellow', 'Vitest', `"providerOptions"${originalName ? ` in "${originalName}" project` : ''} is ignored because it's overridden by the configs. To hide this warning, remove the "providerOptions" property from the browser configuration.`),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@ async function vitest(cliOptions: UserConfig, configValue: UserConfig = {}, vite
|
||||
return vitest
|
||||
}
|
||||
|
||||
test('assignes names as browsers', async () => {
|
||||
test('assigns names as browsers', async () => {
|
||||
const { projects } = await vitest({
|
||||
browser: {
|
||||
enabled: true,
|
||||
@ -45,7 +45,7 @@ test('filters projects', async () => {
|
||||
])
|
||||
})
|
||||
|
||||
test('filters projects with a wildecard', async () => {
|
||||
test('filters projects with a wildcard', async () => {
|
||||
const { projects } = await vitest({
|
||||
project: 'chrom*',
|
||||
browser: {
|
||||
|
||||
@ -426,7 +426,7 @@ test('browser.instances is empty', async () => {
|
||||
expect(stderr).toMatch('"browser.instances" was set in the config, but the array is empty. Define at least one browser config.')
|
||||
})
|
||||
|
||||
test('browser.name filteres all browser.instances are required', async () => {
|
||||
test('browser.name filters all browser.instances are required', async () => {
|
||||
const { stderr } = await runVitest({
|
||||
browser: {
|
||||
enabled: true,
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { test } from "vitest";
|
||||
import { multiply, remainder, subtract, sum } from "../src/math";
|
||||
|
||||
test("Should run function sucessfully", async () => {
|
||||
test("Should run function successfully", async () => {
|
||||
sum(1, 1);
|
||||
subtract(1,2)
|
||||
multiply(3,4)
|
||||
|
||||
@ -897,7 +897,7 @@ describe('merge reports', () => {
|
||||
})
|
||||
|
||||
describe('type checking', () => {
|
||||
test('typechking is reported correctly', async () => {
|
||||
test('typechecking is reported correctly', async () => {
|
||||
const report = await run({
|
||||
'example-1.test-d.ts': ts`
|
||||
test('first', () => {});
|
||||
|
||||
@ -13,7 +13,7 @@ test('same snapshots in single test', async () => {
|
||||
const testFile = join(root, 'same.test.ts')
|
||||
editFile(testFile, s => s.replace(/toMatchInlineSnapshot\(`.*`\)/gs, 'toMatchInlineSnapshot()'))
|
||||
|
||||
// iniital run (create snapshot)
|
||||
// initial run (create snapshot)
|
||||
let vitest = await runVitest({
|
||||
root,
|
||||
include: [testFile],
|
||||
@ -102,7 +102,7 @@ test('same snapshots in multiple tests', async () => {
|
||||
const testFile = join(root, 'same2.test.ts')
|
||||
editFile(testFile, s => s.replace(/toMatchInlineSnapshot\(`.*`\)/gs, 'toMatchInlineSnapshot()'))
|
||||
|
||||
// iniital run (create snapshot)
|
||||
// initial run (create snapshot)
|
||||
let vitest = await runVitest({
|
||||
root,
|
||||
include: [testFile],
|
||||
|
||||
@ -3,7 +3,7 @@ import { join } from 'node:path'
|
||||
import { expect, test } from 'vitest'
|
||||
import { runVitest } from '../../test-utils'
|
||||
|
||||
test('jest-image-sapshot', async () => {
|
||||
test('jest-image-snapshot', async () => {
|
||||
// cleanup snapshot
|
||||
const root = join(import.meta.dirname, 'fixtures/jest-image-snapshot')
|
||||
fs.rmSync(join(root, '__image_snapshots__'), { recursive: true, force: true })
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user