johnp

johnp

Test-Driven React: npm resolution error with jest-styled-components@6.3.1 Page 113

When installing jest-styled-components@6.3.1 in Chapter 4 npm raises a resolution error stating jest-styled-components@6.3.1 is not compatible with styled-components@4.4.1.

I tried upgrading both components to the latest versions but this caused the test
expect(mounted).toHaveStyleRule(‘width’, ‘100%’);
and any subsequent uses of toHaveStyleRule to fail, not finding the style rules in the object.

The error was resolved by using the additional --legacy-peer-deps flag when installing jest-styled-components@6.3.1 which gives toHaveStyleRule to work as expect. However a “command sh -c jest” error is raised when the tests are run although all the tests pass.

Don’t you just love npm/javascript packages!

Cheers

John

Initial npm error report below:

npm resolution error report

2021-03-08T02:14:00.603Z

While resolving: test-driven-carousel@1.0.0
Found: styled-components@4.4.1
node_modules/styled-components
styled-components@"^4.1.1" from the root project

Could not resolve dependency:
peer styled-components@"^2.0.0 || ^3.0.2" from jest-styled-components@6.3.1
node_modules/jest-styled-components
dev jest-styled-components@“6.3.1” from the root project

Fix the upstream dependency conflict, or retry
this command with --force, or --legacy-peer-deps
to accept an incorrect (and potentially broken) dependency resolution.

Raw JSON explanation object:

{
“code”: “ERESOLVE”,
“current”: {
“name”: “styled-components”,
“version”: “4.4.1”,
“whileInstalling”: {
“name”: “test-driven-carousel”,
“version”: “1.0.0”,
“path”: “/home/scooter/Projects/test-driven-carousel”
},
“location”: “node_modules/styled-components”,
“dependents”: [
{
“type”: “prod”,
“name”: “styled-components”,
“spec”: “^4.1.1”,
“from”: {
“location”: “/home/scooter/Projects/test-driven-carousel”
}
}
]
},
“edge”: {
“type”: “peer”,
“name”: “styled-components”,
“spec”: “^2.0.0 || ^3.0.2”,
“error”: “INVALID”,
“from”: {
“name”: “jest-styled-components”,
“version”: “6.3.1”,
“whileInstalling”: {
“name”: “test-driven-carousel”,
“version”: “1.0.0”,
“path”: “/home/scooter/Projects/test-driven-carousel”
},
“location”: “node_modules/jest-styled-components”,
“dependents”: [
{
“type”: “dev”,
“name”: “jest-styled-components”,
“spec”: “6.3.1”,
“from”: {
“location”: “/home/scooter/Projects/test-driven-carousel”
}
}
]
}
},
“peerConflict”: null,
“strictPeerDeps”: false,
“force”: false
}

Popular Pragmatic topics Top

brianokken
Many tasks_proj/tests directories exist in chapters 2, 3, 5 that have tests that use the custom markers smoke and get, which are not decl...
New
mikecargal
Title: Hands-on Rust: question about get_component (page 295) (feel free to respond. “You dug you’re own hole… good luck”) I have somet...
New
JohnS
I can’t setup the Rails source code. This happens in a working directory containing multiple (postgres) Rails apps. With: ruby-3.0.0 s...
New
brian-m-ops
#book-python-testing-with-pytest-second-edition Hi. Thanks for writing the book. I am just learning so this might just of been an issue ...
New
leonW
I ran this command after installing the sample application: $ cards add do something --owner Brian And got a file not found error: Fil...
New
fynn
This is as much a suggestion as a question, as a note for others. Locally the SGP30 wasn’t available, so I ordered a SGP40. On page 53, ...
New
digitalbias
Title: Build a Weather Station with Elixir and Nerves: Problem connecting to Postgres with Grafana on (page 64) If you follow the defau...
New
AufHe
I’m a newbie to Rails 7 and have hit an issue with the bin/Dev script mentioned on pages 112-113. Iteration A1 - Seeing the list of prod...
New
bjnord
Hello @herbert ! Trying to get the very first “Hello, Bracket Terminal!" example to run (p. 53). I develop on an Amazon EC2 instance runn...
New
SlowburnAZ
Getting an error when installing the dependencies at the start of this chapter: could not compile dependency :exla, "mix compile" failed...
New

Other popular topics Top

AstonJ
A thread that every forum needs! Simply post a link to a track on YouTube (or SoundCloud or Vimeo amongst others!) on a separate line an...
New
AstonJ
Or looking forward to? :nerd_face:
New
Exadra37
I am asking for any distro that only has the bare-bones to be able to get a shell in the server and then just install the packages as we ...
New
AstonJ
Continuing the discussion from Thinking about learning Crystal, let’s discuss - I was wondering which languages don’t GC - maybe we can c...
New
wmnnd
Here’s the story how one of the world’s first production deployments of LiveView came to be - and how trying to improve it almost caused ...
New
rustkas
Intensively researching Erlang books and additional resources on it, I have found that the topic of using Regular Expressions is either c...
New
foxtrottwist
A few weeks ago I started using Warp a terminal written in rust. Though in it’s current state of development there are a few caveats (tab...
New
PragmaticBookshelf
Rails 7 completely redefines what it means to produce fantastic user experiences and provides a way to achieve all the benefits of single...
New
PragmaticBookshelf
Author Spotlight Rebecca Skinner @RebeccaSkinner Welcome to our latest author spotlight, where we sit down with Rebecca Skinner, auth...
New
New

Latest in PragProg

View all threads ❯