0.0.3 • Published 2 months ago

vite-plugin-mock-replace v0.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

vite-plugin-mock-replace

npm version

A Plugin to replace files with mock implementations. Useful for replacing implementations with dummy mocks during testing in vitest, storybook etc

Installation

yarn add vite-plugin-mock-replace --dev

or

npm i vite-plugin-mock-replace -D

Usage

Configuration

// e.g vitest.config.js
import { defineConfig } from "vitest/config";
import react from "@vitejs/plugin-react";
import mockReplace from "vite-plugin-mock-replace";

export default defineConfig({
  plugins: [react(), mockReplace()],
});

Matching mock files

The default configuration overrides the following files with their override

Extension based replace

src \
  my-file.ts
  my-file.mock.ts

Folder based replace

src \
  __mocks__ \
    my-file.ts
  my-file.ts
0.0.3

2 months ago

0.0.2

2 months ago

0.0.1

2 months ago