🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

jest-preset-preact

Package Overview
Dependencies
Maintainers
8
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jest-preset-preact

Jest preset for testing Preact apps

4.1.1
latest
Source
npm
Version published
Weekly downloads
13K
41.61%
Maintainers
8
Weekly downloads
 
Created
Source

jest-preset-preact

Jest preset containing all required configuration for writing tests for preact.

Features:

  • Transpiles JSX to h()
  • Aliases for react imports to point to preact/compat
  • Automatically serialize Preact VNodes in snapshots
  • Stub style imports (.css, .less, .sass/scss, etc)
  • Add typeahead preview for filtering in jest's watch mode

Usage

Install it via npm or yarn:

npm install --save-dev jest-preset-preact
# or via yarn
yarn add -D jest-preset-preact

...and add the preset to your jest.config.js file.

// jest.config.js
module.exports = {
	preset: 'jest-preset-preact',
};

You can override the default Babel config by providing your own Babel config file:

// babel.config.js
module.exports = {
  env: {
    test: {
      plugins: [
        [
          "@babel/plugin-transform-react-jsx",
          {
            runtime: "automatic",
            importSource: "preact"
          }
        ]
      ]
    }
  }
}

This, for example, would enable the runtime JSX transform instead of the classic.

License

MIT, see the LICENSE file.

FAQs

Package last updated on 07 Feb 2024

Did you know?

Socket

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