Code Monkey home page Code Monkey logo

Comments (16)

kirkstrobeck avatar kirkstrobeck commented on June 26, 2024 2

Hmm, after a bit more investigation using npm install on CI I can still reproduce the error, so may not be a yarn vs. npm issue.

from jest-glamor-react.

kentcdodds avatar kentcdodds commented on June 26, 2024 1

Interesting. Thanks for filing the issue @kirkstrobeck!

I don't use yarn, so I wont be looking into this myself. If you could dig a little further to figure out whether we can fix this issue or if it's something we need a workaround for to document, then let's make that happen.

Good luck! And thanks!

from jest-glamor-react.

hjylewis avatar hjylewis commented on June 26, 2024 1

OK! so I discovered it fails for me when NODE_ENV=production. In other words:

  • NODE_ENV=production npm test => FAIL
  • npm test => SUCCESS

In fact, this is producible on the tests in this repo.

And our Jenkins and other CI probably set the environment to production.


I believe it has to do with glamor's speedy functionality

The easiest solution for this is to do NODE_ENV=test npm test

from jest-glamor-react.

hjylewis avatar hjylewis commented on June 26, 2024 1

SO! That was an issue but ultimately a different issue was causing the failure on Jenkins.

Problem

In order for jest-glamor-react to get the correct styleSheet, it needs to be using the same instance of glamor that jest is using.

But when there are different versions, npm/yarn will add a different glamor to node_modules/jest-glamor-react/node_modules for this library to use. This results in jest-glamor-react looking at an empty styleSheet

Solution

I believe the solution to this problem would be changing glamor to a peer dependency so that the same instance is used.

from jest-glamor-react.

hjylewis avatar hjylewis commented on June 26, 2024

I am having the same issue where it works locally but not running on Jenkins.

FAIL  src/components/Text/Text.test.js
  ● <Text /> › matches snapshot

    expect(value).toMatchSnapshot()
    
    Received value does not match stored snapshot 1.
    
    - Snapshot
    + Received
    
    -.css-sj857o,
    -[data-css-sj857o] {
    -  font-size: 16px;
    -  line-height: inherit;
    -}
    -
     <span
       data-css-sj857o=""
     >
       Hello, World
     </span>

from jest-glamor-react.

kirkstrobeck avatar kirkstrobeck commented on June 26, 2024

@hjylewis are you using yarn or npm?

from jest-glamor-react.

hjylewis avatar hjylewis commented on June 26, 2024

@kirkstrobeck I'm using npm

from jest-glamor-react.

lewisl9029 avatar lewisl9029 commented on June 26, 2024

I haven't had a chance to look into how this could happen yet, but we seem to be able to reproduce this only if the following are true: 1) --coverage flag is enabled for Jest, 2) NODE_ENV is set to production.

from jest-glamor-react.

kentcdodds avatar kentcdodds commented on June 26, 2024

That's weird... Sorry, I'm not sure what's going on there :-/

from jest-glamor-react.

kirkstrobeck avatar kirkstrobeck commented on June 26, 2024

Not sure that is the solution, since https://github.com/kentcdodds/jest-glamor-react/blob/master/package.json#L57-L59

from jest-glamor-react.

hjylewis avatar hjylewis commented on June 26, 2024

Yeah, just noticed that. The solution might be removing the glamor dependency and leaving the peer one. Haven't tried just yet but that might stop it from installing its own version.


EDIT: I investigated a little more. If the user's version of glamor is older than jest-glamor-react's glamor dependency (2.20.24 right now), it will add it's own node_module and not work because they will be using different instances. Otherwise, it works fine.

from jest-glamor-react.

kentcdodds avatar kentcdodds commented on June 26, 2024

Yeah, we could probably remove it from the dependencies and publish a new version without bumping the major version because I doubt anyone using this doesn't have glamor already. Anyone want to do that?

from jest-glamor-react.

hjylewis avatar hjylewis commented on June 26, 2024

I think that would work..

Or, since this package still uses glamor for some tests, we can move it to a dev dependency so that it doesn't get installed transitively when this package is included as a dependency.

Which makes more sense? I'm still wrapping my head around all these dependency stuff.


Edit: I think my vote is for only having it as a peer dependency. Removes any chance that it will be included on npm install. Then for dev work you can explicitly run npm install glamor.

from jest-glamor-react.

kentcdodds avatar kentcdodds commented on June 26, 2024

Yep, let's move it to devDependencies 👍

from jest-glamor-react.

hjylewis avatar hjylewis commented on June 26, 2024

@kirkstrobeck does that fix your issue? you will have to rm -rf node_modules/ and re npm install

from jest-glamor-react.

kentcdodds avatar kentcdodds commented on June 26, 2024

Try upgrading to the latest version (v4) and see if this issue's resolved.

from jest-glamor-react.

Related Issues (19)

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.