Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,26 @@ It can be used like this:
FASTIFY_AUTOLOAD_TYPESCRIPT=1 node --loader=my-custom-loader index.ts
```

### Vitest mocking with TypeScript and ESM

When testing an application that uses Vitest, TypeScript, and ESM, Vitest may externalize `@fastify/autoload` because it is loaded from `node_modules`. In that case, dynamic `import()` calls made by Autoload run through Node.js instead of Vite, which can prevent Vitest mocks from applying to autoloaded routes or plugins.

Inline `@fastify/autoload` in your Vitest configuration so Vite transforms Autoload together with the rest of your application code:

```ts
import { defineConfig } from 'vitest/config'

export default defineConfig({
test: {
server: {
deps: {
inline: ['@fastify/autoload']
}
}
}
})
```

## Plugin Configuration

Each plugin can be individually configured using the following module properties:
Expand Down