Socket
Socket
Sign inDemoInstall

vitest-canvas-mock

Package Overview
Dependencies
516
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    vitest-canvas-mock

🌗 A module used to mock canvas in Vitest.


Version published
Weekly downloads
186K
increased by13.45%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

vitest-canvas-mock

npm (tag) npm bundle size NPM

Mock canvas when running unit tests with vitest. Uses jest-canvas-mock.

Install

npm install vitest-canvas-mock -D

Usage

  1. Create a new setup file that imports vitest-canvas-mock or add it to an existing setup file.
// vitest.setup.ts
import 'vitest-canvas-mock'
  1. In your vitest.config.ts file, create a setupFiles array and add that file:
import { defineConfig } from 'vitest/config'

export default defineConfig({
  test: {
    setupFiles: ['./vitest.setup.ts'],
    environment: 'jsdom',
    deps: {
      inline: ['vitest-canvas-mock'],
    },
    // For this config, check https://github.com/vitest-dev/vitest/issues/740
    threads: false,
    environmentOptions: {
      jsdom: {
        resources: 'usable',
      },
    },
  },
})

Mock Strategy

View mock strategy doc here.

Snapshots

View snapshots doc here

License

MIT

Keywords

FAQs

Last updated on 09 Aug 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc