Skip to content

Commit

Permalink
docs: remove irrelevant vitest.config references and update the sid…
Browse files Browse the repository at this point in the history
…ebar (#7006)
  • Loading branch information
sheremet-va authored Dec 2, 2024
1 parent 6a260ce commit 2324375
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 53 deletions.
44 changes: 25 additions & 19 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import { withPwa } from '@vite-pwa/vitepress'
import type { DefaultTheme } from 'vitepress'
import { defineConfig } from 'vitepress'
import { tabsMarkdownPlugin } from 'vitepress-plugin-tabs'
import {
groupIconMdPlugin,
groupIconVitePlugin,
} from 'vitepress-plugin-group-icons'
import { version } from '../../package.json'
import { teamMembers } from './contributors'
import {
Expand All @@ -20,10 +24,6 @@ import {
} from './meta'
import { pwa } from './scripts/pwa'
import { transformHead } from './scripts/transformHead'
import {
groupIconMdPlugin,
groupIconVitePlugin,
} from 'vitepress-plugin-group-icons'

export default ({ mode }: { mode: string }) => {
return withPwa(defineConfig({
Expand Down Expand Up @@ -145,7 +145,7 @@ export default ({ mode }: { mode: string }) => {
text: 'Resources',
items: [
{
text: 'Advanced',
text: 'Advanced API',
link: '/advanced/api',
activeMatch: '^/advanced/',
},
Expand Down Expand Up @@ -311,6 +311,10 @@ export default ({ mode }: { mode: string }) => {
text: 'Advanced API',
link: '/advanced/api',
},
{
text: 'Comparisons',
link: '/guide/comparisons',
},
],
},
],
Expand Down Expand Up @@ -359,10 +363,6 @@ function introduction(): DefaultTheme.SidebarItem[] {

function guide(): DefaultTheme.SidebarItem[] {
return [
{
text: 'Workspace',
link: '/guide/workspace',
},
{
text: 'CLI',
link: '/guide/cli',
Expand All @@ -371,6 +371,10 @@ function guide(): DefaultTheme.SidebarItem[] {
text: 'Test Filtering',
link: '/guide/filtering',
},
{
text: 'Workspace',
link: '/guide/workspace',
},
{
text: 'Reporters',
link: '/guide/reporters',
Expand Down Expand Up @@ -419,10 +423,6 @@ function guide(): DefaultTheme.SidebarItem[] {
text: 'Debugging',
link: '/guide/debugging',
},
{
text: 'Comparisons',
link: '/guide/comparisons',
},
{
text: 'Migration Guide',
link: '/guide/migration',
Expand All @@ -432,12 +432,18 @@ function guide(): DefaultTheme.SidebarItem[] {
link: '/guide/common-errors',
},
{
text: 'Profiling Test Performance',
link: '/guide/profiling-test-performance',
},
{
text: 'Improving Performance',
link: '/guide/improving-performance',
text: 'Performance',
collapsed: false,
items: [
{
text: 'Profiling Test Performance',
link: '/guide/profiling-test-performance',
},
{
text: 'Improving Performance',
link: '/guide/improving-performance',
},
],
},
]
}
Expand Down
60 changes: 30 additions & 30 deletions docs/config/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ This option will also affect if a file should be treated as a module when extern

Setting this option will _override_ the default, if you wish to still search `node_modules` for packages include it along with any other options:

```ts [vitest.config.js]
```ts
import { defineConfig } from 'vitest/config'

export default defineConfig({
Expand Down Expand Up @@ -442,7 +442,7 @@ Vitest uses Vite SSR primitives to run tests which has [certain pitfalls](https:

By default, `vitest` does not provide global APIs for explicitness. If you prefer to use the APIs globally like Jest, you can pass the `--globals` option to CLI or add `globals: true` in the config.

```ts [vitest.config.js]
```ts
import { defineConfig } from 'vitest/config'

export default defineConfig({
Expand Down Expand Up @@ -607,7 +607,7 @@ Automatically assign environment based on globs. The first match will be used.

For example:

```ts [vitest.config.js]
```ts
import { defineConfig } from 'vitest/config'

export default defineConfig({
Expand Down Expand Up @@ -654,7 +654,7 @@ Automatically assign pool in which tests will run based on globs. The first matc

For example:

```ts [vitest.config.js]
```ts
import { defineConfig } from 'vitest/config'

export default defineConfig({
Expand Down Expand Up @@ -773,7 +773,7 @@ Similar as `vmThreads` pool but uses `child_process` instead of `worker_threads`

Options for `threads` pool.

```ts [vitest.config.js]
```ts
import { defineConfig } from 'vitest/config'

export default defineConfig({
Expand Down Expand Up @@ -845,7 +845,7 @@ Be careful when using, it as some options may crash worker, e.g. --prof, --title

Options for `forks` pool.

```ts [vitest.config.js]
```ts
import { defineConfig } from 'vitest/config'

export default defineConfig({
Expand Down Expand Up @@ -908,7 +908,7 @@ Be careful when using, it as some options may crash worker, e.g. --prof, --title

Options for `vmThreads` pool.

```ts [vitest.config.js]
```ts
import { defineConfig } from 'vitest/config'

export default defineConfig({
Expand Down Expand Up @@ -989,7 +989,7 @@ Be careful when using, it as some options may crash worker, e.g. --prof, --title

Options for `vmForks` pool.

```ts [vitest.config.js]
```ts
import { defineConfig } from 'vitest/config'

export default defineConfig({
Expand Down Expand Up @@ -1144,7 +1144,7 @@ export default defineConfig({
},
})
```
```ts [my.test.js]
```ts [api.test.js]
import { expect, inject, test } from 'vitest'

test('api key is defined', () => {
Expand Down Expand Up @@ -1334,7 +1334,7 @@ List of files excluded from coverage as glob patterns.

This option overrides all default options. Extend the default options when adding new patterns to ignore:

```ts [vitest.config.js]
```ts
import { coverageConfigDefaults, defineConfig } from 'vitest/config'

export default defineConfig({
Expand Down Expand Up @@ -1623,7 +1623,7 @@ By default Vite uses ESBuild which removes comments and Typescript types from `.

If you want to apply ESBuild to other files as well, define them in [`esbuild` options](https://vitejs.dev/config/shared-options.html#esbuild):

```ts [vitest.config.js]
```ts
import { defineConfig } from 'vitest/config'

export default defineConfig({
Expand Down Expand Up @@ -1829,18 +1829,20 @@ This is an advanced API for library authors. If you just need to run tests in a

Options that will be passed down to provider when calling `provider.initialize`.

```ts [vitest.config.js]
export default {
```ts
import { defineConfig } from 'vitest/config'

export default defineConfig({
test: {
browser: {
providerOptions: {
launch: {
devtools: true,
}
}
}
}
}
},
},
},
},
})
```

::: tip
Expand Down Expand Up @@ -2031,7 +2033,7 @@ A list of paths to snapshot serializer modules for snapshot testing, useful if y

Overrides default snapshot path. For example, to store snapshots next to test files:

```ts [vitest.config.js]
```ts
import { defineConfig } from 'vitest/config'

export default defineConfig({
Expand Down Expand Up @@ -2136,7 +2138,7 @@ Use this option if you want to disable the cache feature. At the moment Vitest s

The cache directory is controlled by the Vite's [`cacheDir`](https://vitejs.dev/config/shared-options.html#cachedir) option:

```ts [vitest.config.js]
```ts
import { defineConfig } from 'vitest/config'

export default defineConfig({
Expand All @@ -2146,7 +2148,7 @@ export default defineConfig({

You can limit the directory only for Vitest by using `process.env.VITEST`:

```ts [vitest.config.js]
```ts
import { defineConfig } from 'vitest/config'

export default defineConfig({
Expand Down Expand Up @@ -2379,7 +2381,7 @@ Custom handler for `console.log` in tests. If you return `false`, Vitest will no

Can be useful for filtering out logs from third-party libraries.

```ts [vitest.config.js]
```ts
import { defineConfig } from 'vitest/config'

export default defineConfig({
Expand All @@ -2399,7 +2401,7 @@ Apply a filtering function to each frame of each stack trace when handling error

Can be useful for filtering out stack trace frames from third-party libraries.

```ts [vitest.config.ts]
```ts
import type { ParsedStack } from 'vitest'
import { defineConfig } from 'vitest/config'

Expand Down Expand Up @@ -2429,8 +2431,7 @@ export default defineConfig({

For example, as a config object:

:::code-group
```ts [vitest.config.js]
```ts
import { defineConfig } from 'vitest/config'
import c from 'picocolors'

Expand All @@ -2440,11 +2441,10 @@ export default defineConfig({
aIndicator: c.bold('--'),
bIndicator: c.bold('++'),
omitAnnotationLines: true,
}
}
},
},
})
```
:::

Or as a module:

Expand All @@ -2454,8 +2454,8 @@ import { defineConfig } from 'vitest/config'

export default defineConfig({
test: {
diff: './vitest.diff.ts'
}
diff: './vitest.diff.ts',
},
})
```

Expand Down
2 changes: 1 addition & 1 deletion docs/guide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Vitest requires Vite >=v5.0.0 and Node >=v18.0.0

It is recommended that you install a copy of `vitest` in your `package.json`, using one of the methods listed above. However, if you would prefer to run `vitest` directly, you can use `npx vitest` (the `npx` tool comes with npm and Node.js).

The `npx` tool will execute the specified command. By default, `npx` will first check if the command exists in the local project's binaries. If it is not found there, `npx` will look in the system's $PATH and execute it if found. If the command is not found in either location, `npx` will install it in a temporary location prior to execution.
The `npx` tool will execute the specified command. By default, `npx` will first check if the command exists in the local project's binaries. If it is not found there, `npx` will look in the system's `$PATH` and execute it if found. If the command is not found in either location, `npx` will install it in a temporary location prior to execution.

## Writing Tests

Expand Down
4 changes: 2 additions & 2 deletions docs/guide/mocking.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ title: Mocking | Guide

# Mocking

When writing tests it's only a matter of time before you need to create a "fake" version of an internal — or external — service. This is commonly referred to as **mocking**. Vitest provides utility functions to help you out through its **vi** helper. You can `import { vi } from 'vitest'` or access it **globally** (when [global configuration](/config/#globals) is **enabled**).
When writing tests it's only a matter of time before you need to create a "fake" version of an internal — or external — service. This is commonly referred to as **mocking**. Vitest provides utility functions to help you out through its `vi` helper. You can import it from `vitest` or access it globally if [`global` configuration](/config/#globals) is enabled.

::: warning
Always remember to clear or restore mocks before or after each test run to undo mock state changes between runs! See [`mockReset`](/api/mock#mockreset) docs for more info.
:::

If you wanna dive in head first, check out the [API section](/api/vi) otherwise keep reading to take a deeper dive into the world of mocking.
If you are not familliar with `vi.fn`, `vi.mock` or `vi.spyOn` methods, check the [API section](/api/vi) first.

## Dates

Expand Down
2 changes: 1 addition & 1 deletion docs/guide/testing-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Since Vitest 2.1, if your `include` and `typecheck.include` overlap, Vitest will

Using CLI flags, like `--allowOnly` and `-t` are also supported for type checking.

```ts
```ts [mount.test-d.ts]
import { assertType, expectTypeOf } from 'vitest'
import { mount } from './mount.js'

Expand Down

0 comments on commit 2324375

Please sign in to comment.