Skip to content

Styled-JSX and Jest #265

Answered by varl
varl asked this question in Gotchas
Discussion options

You must be logged in to vote

Copied from the original post:

TL;DR (recommended setup)

Usage of styled-jsx css and css.resolve function

In your code-base, make sure to import the resolve function from the named export, like so:

import { resolve } from 'styled-jsx/css';
const buttonStyle = resolve`button { color: green; }`;

and not as property of the css function, i.e. do not do this:

import css from 'styled-jsx/css';
const buttonStyle = css.resolve`button { color: green; }`;

Mocking the css and css.resolve function

Create a mock file in the project root, adjacent to the node_modules folder: ./__mocks__/styled-jsx/css.js

module.exports.__esModule = true;
module.exports.default = () => 'default';
module.exports.resolve =

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by varl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant