Skip to content

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

License

Notifications You must be signed in to change notification settings

Verthon/vitest-offline

Repository files navigation

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",
	},
});

About

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

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published