Skip to content

Commit

Permalink
Merge branch 'main' into test-vite-18983
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa committed Dec 25, 2024
2 parents f6a9236 + b700d26 commit d32ce4c
Show file tree
Hide file tree
Showing 143 changed files with 3,925 additions and 2,157 deletions.
32 changes: 0 additions & 32 deletions .github/workflows/bench.yml

This file was deleted.

15 changes: 2 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ jobs:

test-browser:
needs: changed
name: 'Browser: ${{ matrix.browser[0] }}, ${{ matrix.os }}'
name: 'Browsers: node-20, ${{ matrix.os }}'
if: needs.changed.outputs.should_skip != 'true'

runs-on: ${{ matrix.os }}
Expand All @@ -133,10 +133,6 @@ jobs:
os:
- macos-latest
- windows-latest
browser:
- [chromium, chrome]
- [firefox, firefox]
- [webkit]
fail-fast: false

timeout-minutes: 30
Expand All @@ -149,26 +145,19 @@ jobs:
node-version: 20

- uses: browser-actions/setup-chrome@v1
if: ${{ matrix.browser[0] == 'chromium' }}
- uses: browser-actions/setup-firefox@v1
if: ${{ matrix.browser[0] == 'firefox' }}

- name: Install
run: pnpm i

- name: Install Playwright Dependencies
run: pnpm exec playwright install ${{ matrix.browser[0] }} --with-deps --only-shell
run: pnpm exec playwright install --with-deps --only-shell

- name: Build
run: pnpm run build

- name: Test Browser (playwright)
run: pnpm run test:browser:playwright
env:
BROWSER: ${{ matrix.browser[0] }}

- name: Test Browser (webdriverio)
run: pnpm run test:browser:webdriverio
if: ${{ matrix.browser[1] }}
env:
BROWSER: ${{ matrix.browser[1] }}
33 changes: 33 additions & 0 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export default ({ mode }: { mode: string }) => {
groupIconVitePlugin({
customIcon: {
'CLI': 'vscode-icons:file-type-shell',
'vitest.shims': 'vscode-icons:file-type-vitest',
'vitest.workspace': 'vscode-icons:file-type-vitest',
'vitest.config': 'vscode-icons:file-type-vitest',
'.spec.ts': 'vscode-icons:file-type-testts',
Expand Down Expand Up @@ -214,6 +215,27 @@ export default ({ mode }: { mode: string }) => {
},
],
},
{
text: 'Configuration',
collapsed: false,
items: [
{
text: 'Browser Config Reference',
link: '/guide/browser/config',
docFooterText: 'Browser Config Reference | Browser Mode',
},
{
text: 'Configuring Playwright',
link: '/guide/browser/playwright',
docFooterText: 'Configuring Playwright | Browser Mode',
},
{
text: 'Configuring WebdriverIO',
link: '/guide/browser/webdriverio',
docFooterText: 'Configuring WebdriverIO | Browser Mode',
},
],
},
{
text: 'API',
collapsed: false,
Expand Down Expand Up @@ -245,6 +267,17 @@ export default ({ mode }: { mode: string }) => {
},
],
},
{
text: 'Guides',
collapsed: false,
items: [
{
text: 'Multiple Setups',
link: '/guide/browser/multiple-setups',
docFooterText: 'Multiple Setups | Browser Mode',
},
],
},
{
items: [
...footer(),
Expand Down
2 changes: 1 addition & 1 deletion docs/.vitepress/scripts/cli-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const options = resolveOptions(cliOptionsConfig)
const template = options.map((option) => {
const title = option.title
const cli = option.cli
const config = skipConfig.has(title) ? '' : `[${title}](/config/#${title.toLowerCase().replace(/\./g, '-')})`
const config = skipConfig.has(title) ? '' : `[${title}](${title.includes('browser.') ? '/guide/browser/config' : '/config/'}#${title.toLowerCase().replace(/\./g, '-')})`
return `### ${title}\n\n- **CLI:** ${cli}\n${config ? `- **Config:** ${config}\n` : ''}\n${option.description}\n`
}).join('\n')

Expand Down
9 changes: 8 additions & 1 deletion docs/advanced/api/vitest.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ Vitest 3 is one step closer to stabilising the public API. To achieve that, we d
- `changeNamePattern`
- `changeFilenamePattern`
- `rerunFailed`
- `updateSnapshot`
- `_createRootProject` (renamed to `_ensureRootProject`, but still private)
- `filterTestsBySource` (this was moved to the new internal `vitest.specifications` instance)
- `runFiles` (use [`runTestSpecifications`](#runtestspecifications) instead)
Expand Down Expand Up @@ -326,6 +325,14 @@ function runTestSpecifications(

This method emits `reporter.onWatcherRerun` and `onTestsRerun` events, then it runs tests with [`runTestSpecifications`](#runtestspecifications). If there were no errors in the main process, it will emit `reporter.onWatcherStart` event.

## updateSnapshot

```ts
function updateSnapshot(files?: string[]): Promise<TestRunResult>
```

Update snapshots in specified files. If no files are provided, it will update files with failed tests and obsolete snapshots.

## collectTests

```ts
Expand Down
4 changes: 2 additions & 2 deletions docs/api/assert.md
Original file line number Diff line number Diff line change
Expand Up @@ -1688,10 +1688,10 @@ Asserts that a `modifier` increases a numeric `object`'s `property` or a `modifi
```ts
import { assert, test } from 'vitest'

test('assert.increases', () => {
test('assert.increasesBy', () => {
const obj = { val: 10 }
function fn() { obj.val += 10 };
assert.increases(fn, obj, 'val', 10)
assert.increasesBy(fn, obj, 'val', 10)
})
```

Expand Down
36 changes: 36 additions & 0 deletions docs/api/expect.md
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,42 @@ test('getApplesCount has some unusual side effects...', () => {
})
```

## toBeOneOf

- **Type:** `(sample: Array<any>) => any`

`toBeOneOf` asserts if a value matches any of the values in the provided array.

```ts
import { expect, test } from 'vitest'

test('fruit is one of the allowed values', () => {
expect(fruit).toBeOneOf(['apple', 'banana', 'orange'])
})
```

The asymmetric matcher is particularly useful when testing optional properties that could be either `null` or `undefined`:

```ts
test('optional properties can be null or undefined', () => {
const user = {
firstName: 'John',
middleName: undefined,
lastName: 'Doe'
}

expect(user).toEqual({
firstName: expect.any(String),
middleName: expect.toBeOneOf([expect.any(String), undefined]),
lastName: expect.any(String),
})
})
```

:::tip
You can use `expect.not` with this matcher to ensure a value does NOT match any of the provided options.
:::

## toBeTypeOf

- **Type:** `(c: 'bigint' | 'boolean' | 'function' | 'number' | 'object' | 'string' | 'symbol' | 'undefined') => Awaitable<void>`
Expand Down
18 changes: 9 additions & 9 deletions docs/api/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ test.skipIf(isDev)('prod only test', () => {
```

::: warning
You cannot use this syntax, when using Vitest as [type checker](/guide/testing-types).
You cannot use this syntax when using Vitest as [type checker](/guide/testing-types).
:::

### test.runIf
Expand All @@ -166,7 +166,7 @@ test.runIf(isDev)('dev only test', () => {
```

::: warning
You cannot use this syntax, when using Vitest as [type checker](/guide/testing-types).
You cannot use this syntax when using Vitest as [type checker](/guide/testing-types).
:::

### test.only
Expand Down Expand Up @@ -231,7 +231,7 @@ test.concurrent('test 2', async ({ expect }) => {
```

::: warning
You cannot use this syntax, when using Vitest as [type checker](/guide/testing-types).
You cannot use this syntax when using Vitest as [type checker](/guide/testing-types).
:::

### test.sequential
Expand Down Expand Up @@ -289,7 +289,7 @@ test.fails('fail test', async () => {
```

::: warning
You cannot use this syntax, when using Vitest as [type checker](/guide/testing-types).
You cannot use this syntax when using Vitest as [type checker](/guide/testing-types).
:::

### test.each
Expand Down Expand Up @@ -390,7 +390,7 @@ Vitest processes `$values` with Chai `format` method. If the value is too trunca
:::

::: warning
You cannot use this syntax, when using Vitest as [type checker](/guide/testing-types).
You cannot use this syntax when using Vitest as [type checker](/guide/testing-types).
:::

### test.for
Expand Down Expand Up @@ -800,7 +800,7 @@ describe.runIf(isDev)('dev only test suite', () => {
```

::: warning
You cannot use this syntax, when using Vitest as [type checker](/guide/testing-types).
You cannot use this syntax when using Vitest as [type checker](/guide/testing-types).
:::

### describe.only
Expand Down Expand Up @@ -874,7 +874,7 @@ describe.concurrent('suite', () => {
```

::: warning
You cannot use this syntax, when using Vitest as [type checker](/guide/testing-types).
You cannot use this syntax when using Vitest as [type checker](/guide/testing-types).
:::

### describe.sequential
Expand Down Expand Up @@ -930,7 +930,7 @@ describe.shuffle('suite', () => {
`.skip`, `.only`, and `.todo` works with random suites.

::: warning
You cannot use this syntax, when using Vitest as [type checker](/guide/testing-types).
You cannot use this syntax when using Vitest as [type checker](/guide/testing-types).
:::

### describe.todo
Expand Down Expand Up @@ -995,7 +995,7 @@ describe.each`
```

::: warning
You cannot use this syntax, when using Vitest as [type checker](/guide/testing-types).
You cannot use this syntax when using Vitest as [type checker](/guide/testing-types).
:::

## Setup and Teardown
Expand Down
Loading

0 comments on commit d32ce4c

Please sign in to comment.