Skip to content

Latest commit

 

History

History
46 lines (33 loc) · 689 Bytes

README.md

File metadata and controls

46 lines (33 loc) · 689 Bytes

vitest-offline

Simple addon to your vitest, that will break tests if any of them make a network request.

Install

With npm:

npm i -D vitest-offline

With pnpm:

pnpm add -D vitest-offline

With yarn:

yarn add vitest-offline --dev

Use

In your vitest setup file add following code:

// e.g. src/setupTests.ts

import { setupNetworkInterceptor } from "vitest-offline";

setupNetworkInterceptor();

Import to your Vite config file:

// vitest.config.mts or vite.config.mts

export default defineConfig({
	test: {
		...
    // make sure it is correct path to your setupTests file
		setupFiles: "./src/setupTests.ts",
	},
});