Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/preactjs/jest-preset-preact
Jest preset for testing Preact apps
https://github.com/preactjs/jest-preset-preact
jest preact preset testing
Last synced: about 1 month ago
JSON representation
Jest preset for testing Preact apps
- Host: GitHub
- URL: https://github.com/preactjs/jest-preset-preact
- Owner: preactjs
- License: mit
- Created: 2020-06-15T18:50:51.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-02-07T16:51:11.000Z (9 months ago)
- Last Synced: 2024-04-14T13:08:33.906Z (7 months ago)
- Topics: jest, preact, preset, testing
- Language: JavaScript
- Size: 200 KB
- Stars: 20
- Watchers: 4
- Forks: 12
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# jest-preset-preact
Jest preset containing all required configuration for writing tests for [preact](https://github.com/preactjs/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:
```bash
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.
```js
// jest.config.js
module.exports = {
preset: 'jest-preset-preact',
};
```You can override the default Babel config by providing your own Babel config file:
```js
// 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](./LICENSE).