# @stylable/jest

> Test your Stylable React components using Jest

Latest version **6.1.1** (published 2024-05-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install @stylable/jest
pnpm add @stylable/jest
yarn add @stylable/jest
bun add @stylable/jest
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 6.1.1 |
| Published | 2024-05-30 |
| First published | 2018-08-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=18.12.0 |
| Dependencies | 5 |
| Unpacked size | 12.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1275 |
| Author | Wix.com |
| Maintainers | tomrav, avi.vahl, idoros, baraki, cijoe, alexswix |

## Links

- npm: https://www.npmjs.com/package/@stylable/jest
- Repository: https://github.com/wix/stylable.git#master
- Homepage: https://github.com/wix/stylable/tree/master#readme
- Issues: https://github.com/wix/stylable/issues
- npm.io page: https://npm.io/package/@stylable/jest

## Dependencies (5)

- [@stylable/core](https://npm.io/package/@stylable/core.md) ^6.1.1
- [@stylable/node](https://npm.io/package/@stylable/node.md) ^6.1.1
- [@stylable/runtime](https://npm.io/package/@stylable/runtime.md) ^6.1.1
- [@file-services/node](https://npm.io/package/@file-services/node.md) ^9.3.0
- [@stylable/module-utils](https://npm.io/package/@stylable/module-utils.md) ^6.1.1

## Recent versions

- 6.1.1 (latest) — 2024-05-30
- 5.19.0 (release-5.x) — 2024-03-05
- 6.0.0-rc.3 (next) — 2024-02-01
- 4.15.1 (release-4.x) — 2022-08-14
- 3.13.2 (release-3.x) — 2021-12-09
- 1.4.0 (release-1.x) — 2020-03-05
- 6.1.0 — 2024-05-21
- 6.0.2 — 2024-04-15
- 6.0.1 — 2024-03-19
- 6.0.0 — 2024-03-13
- 5.18.1 — 2024-02-12
- 5.18.0 — 2024-01-14
- 5.17.0 — 2023-12-03
- 6.0.0-rc.2 — 2023-11-08
- 6.0.0-rc.1 — 2023-11-08
- … 211 more at https://npm.io/package/@stylable/jest/versions

## README

# @stylable/jest

[![npm version](https://img.shields.io/npm/v/@stylable/jest.svg)](https://www.npmjs.com/package/@stylable/jest)

`@stylable/jest` is a simple integration that allows testing your Stylable React components using [Jest](https://jestjs.io/).

## Installation

Install `@stylable/jest` as a dev dependency in your local project.

Install using npm:
```bash
npm install @stylable/jest --save-dev
```

Install using yarn:
```bash
yarn add @stylable/jest --dev
```

## Usage

Add the transformer to your `jest.config.js` file:

```js
module.exports = {
  transform: {
    '\\.st\\.css?$': '@stylable/jest',
  }
};
```

### Configuring Stylable options

See the interface for `StylableConfig` [here](https://github.com/wix/stylable/blob/master/packages/core/src/stylable.ts).

```js
module.exports = {
  transform: {
    '\\.st\\.css?$': ['@stylable/jest', { stylable: { /* Stylable options */ } }],
  }
};
```

### Ignore Stylable files from exsiting css integrations
To prevent existing CSS integrations from affecting Stylable files, ignore '.st.css' in the integration configuration.

Change: 
```js
"moduleNameMapper": {
  "\\.(css|scss)$": "SOME_MOCK_PATH"
},
```
To:
```js
"moduleNameMapper": {
  "(?<!\\.st)\\.(css|scss)$": "SOME_MOCK_PATH"
},
```

### Ignoring `node_modules` stylesheets

To disable transformation for stylehseets originating from your `node_modules` add the following configuration:

```js
module.exports = {
  // existing configuration...
  
  transformIgnorePatterns: [
    '/node_modules/(?!(.*?\\.st\\.css$))', // libraries publish .st.css files in their dist
  ],
};
```

## License

Copyright (c) 2017 Wix.com Ltd. All Rights Reserved. Use of this source code is governed by a [MIT license](./LICENSE).

---
_Source: https://npm.io/package/@stylable/jest · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
