Test your Stylable React components using Jest
npm install @stylable/jest
@stylable/jest is a simple integration that allows testing your Stylable React components using Jest.
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
Add the transformer to your jest.config.js file:
`js`
module.exports = {
transform: {
'\\.st\\.css?$': '@stylable/jest',
}
};
See the interface for StylableConfig here.
`js`
module.exports = {
transform: {
'\\.st\\.css?$': ['@stylable/jest', { stylable: { / Stylable options / } }],
}
};
Change:
`js`
"moduleNameMapper": {
"\\.(css|scss)$": "SOME_MOCK_PATH"
},`
To:js`
"moduleNameMapper": {
"(?},
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
],
};
Copyright (c) 2017 Wix.com Ltd. All Rights Reserved. Use of this source code is governed by a MIT license.