vitest-offline
v1.0.0
Published
Addon for your Vitest configuration, which will fail tests that make a network requests.
Downloads
3
Readme
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",
},
});