Skip to content

Commit

Permalink
Add filenames to code snippets under Setup docs page (#540)
Browse files Browse the repository at this point in the history
  • Loading branch information
Unclemortuary committed Jan 2, 2023
1 parent 30a420e commit d670f40
Showing 1 changed file with 5 additions and 6 deletions.
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

0 comments on commit d670f40

Please sign in to comment.