Giter Site home page Giter Site logo

jaredlunde / jest-stitches Goto Github PK

View Code? Open in Web Editor NEW
16.0 3.0 1.0 178 KB

Jest utilities for Stitches

Home Page: https://npmjs.com/package/jest-stitches

License: MIT License

JavaScript 100.00%
stitches stitches-utils jest-snapshots jest-matchers jest

jest-stitches's People

Contributors

jaredlunde avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

atom-learning

jest-stitches's Issues

`:root` included in snapshot

Describe the bug

I'm adding this as a bug rather than a feature request as this behaviour has changed when upgrading to the latest beta version of stitches. Previously jest-stitches would collate all the relevant classes and render them in the snapshot but would not include the :root pseudo-class containing the stitches theme, I think this is the correct behaviour as :root level custom properties are not specific to the component.

To Reproduce

Create a generic styled component from stitches alongside a test using jest-stitches

import { createCss } from '@stitches/react'

const { styled } = createCss({
  theme: {
    colors: { primary: 'red' }
  }
})

export const Box = styled('div', {})
import { render, screen } from '@testing-library/react'
import * as React from 'react'

import { Box } from './'

describe(`Box component`, () => {
  it('renders', async () => {
    const { container } = render(
      <Box css={{ color: '$primary' }}>BOX</Box>
    )
    await screen.findByText('BOX')
    expect(container).toMatchSnapshot()
  })
})

jest.config.js

module.exports = {
  snapshotSerializers: ['jest-stitches']
}

Expected behavior

Expect to see relevant classes from styled component and css, but not document level :root class.

// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Box component renders 1`] = `
:root {
  --colors-primary: red;
}

.sx03kze4nwvh--css {
  color: var(--colors-primary);
}

<div>
  <div
    class="sx03kze sx03kze4nwvh--css"
  >
    BOX
  </div>
</div>
`;

Additional context

Package versions

"@stitches/react": "0.1.0-canary.3",
"jest": "26.6.3",
"jest-dom": "4.0.0",
"jest-stitches": "1.0.4"

Let me know if you need any additional context or detail with the issue, thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.