Comments (16)
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.
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.
OK! so I discovered it fails for me when NODE_ENV=production
. In other words:
NODE_ENV=production npm test
=> FAILnpm 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.
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.
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.
@hjylewis are you using yarn
or npm
?
from jest-glamor-react.
@kirkstrobeck I'm using npm
from jest-glamor-react.
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.
That's weird... Sorry, I'm not sure what's going on there :-/
from jest-glamor-react.
Not sure that is the solution, since https://github.com/kentcdodds/jest-glamor-react/blob/master/package.json#L57-L59
from jest-glamor-react.
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.
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.
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.
Yep, let's move it to devDependencies 👍
from jest-glamor-react.
@kirkstrobeck does that fix your issue? you will have to rm -rf node_modules/
and re npm install
from jest-glamor-react.
Try upgrading to the latest version (v4) and see if this issue's resolved.
from jest-glamor-react.
Related Issues (19)
- Use placeholder classnames HOT 4
- Help setting up snapshots HOT 19
- Jest configuration - test environment value HOT 3
- Setup instructions unclear HOT 2
- Placeholder classnames doesn't seem to work HOT 9
- css- prefixed selectors are not replaced if the component has no styles HOT 1
- Sort CSS output? HOT 13
- Should this work with babel-plugin-glamorous-displayname HOT 3
- Inconsistent Snapshots on CI HOT 7
- glamorous-native version ? HOT 2
- Is there any ways to get style for pseudo-class? HOT 6
- Support expect matchers on value field HOT 1
- Snapshot testing of DOM element clears out that elements children HOT 6
- EDIT: Solved, user error. --- No styles output in snapshot HOT 1
- Locally linked repos do not have their components styles transformed HOT 3
- Support providing custom StyleSheet instance. HOT 2
- Last release failed HOT 1
- Thanks! HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jest-glamor-react.