Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add filenames to code snippets under Setup docs page #540

Merged
merged 2 commits into from Jan 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 5 additions & 6 deletions website/docs/getting-started/setup.md
Expand Up @@ -10,8 +10,7 @@ sidebar_position: 2

Create a setup script with the following:

```javascript
// ./testSetup.js
```javascript title="testSetup.js"

// add all jest-extended matchers
import * as matchers from 'jest-extended';
Expand All @@ -24,15 +23,15 @@ expect.extend({ toBeArray, toBeSealed });

Add your setup script to your Jest `setupFilesAfterEnv` configuration. [See for help](https://jestjs.io/docs/en/configuration.html#setupfilesafterenv-array)

```json
```json title="package.json"
"jest": {
"setupFilesAfterEnv": ["./testSetup.js"]
}
```

To automatically extend `expect` with all matchers, you can use

```json
```json title="package.json"
"jest": {
"setupFilesAfterEnv": ["jest-extended/all"]
}
Expand All @@ -42,15 +41,15 @@ To automatically extend `expect` with all matchers, you can use

`jest-extended` works with `vitest` because their `expect.extend` API is compatible. In your setup script:

```javascript
```javascript title="testSetup.js"
import {expect} from "vitest";
import * as matchers from "jest-extended";
expect.extend(matchers);
```

Add this setup script to your `vitest.config.js`:

```javascript
```javascript title="vitest.config.js"
export default defineConfig({
test: {
setupFiles: ["./testSetup.js"],
Expand Down