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
}

Where Next?

Popular Pragmatic Bookshelf topics Top

New
Alexandr
Hi everyone! There is an error on the page 71 in the book “Programming machine learning from coding to depp learning” P. Perrotta. You c...
New
simonpeter
When I try the command to create a pair of migration files I get an error. user=> (create-migration "guestbook") Execution error (Ill...
New
edruder
I thought that there might be interest in using the book with Rails 6.1 and Ruby 2.7.2. I’ll note what I needed to do differently here. ...
New
lirux
Hi Jamis, I think there’s an issue with a test on chapter 6. I own the ebook, version P1.0 Feb. 2019. This test doesn’t pass for me: ...
New
herminiotorres
Hi! I know not the intentions behind this narrative when called, on page XI: mount() |> handle_event() |> render() but the correc...
New
conradwt
First, the code resources: Page 237: rumbl_umbrella/apps/rumbl/mix.exs Note: That this file is missing. Page 238: rumbl_umbrella/app...
New
akraut
The markup used to display the uploaded image results in a Phoenix.LiveView.HTMLTokenizer.ParseError error. lib/pento_web/live/product_l...
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
dachristenson
I just bought this book to learn about Android development, and I’m already running into a major issue in Ch. 1, p. 20: “Update activity...
New

Other popular topics Top

Exadra37
Oh just spent so much time on this to discover now that RancherOS is in end of life but Rancher is refusing to mark the Github repo as su...
New
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
AstonJ
Saw this on TikTok of all places! :lol: Anyone heard of them before? Lite:
New
PragmaticBookshelf
Build efficient applications that exploit the unique benefits of a pure functional language, learning from an engineer who uses Haskell t...
New
New
First poster: joeb
The File System Access API with Origin Private File System. WebKit supports new API that makes it possible for web apps to create, open,...
New
AstonJ
If you want a quick and easy way to block any website on your Mac using Little Snitch simply… File > New Rule: And select Deny, O...
New
PragmaticBookshelf
Author Spotlight: VM Brasseur @vmbrasseur We have a treat for you today! We turn the spotlight onto Open Source as we sit down with V...
New
PragmaticBookshelf
Author Spotlight: Karl Stolley @karlstolley Logic! Rhetoric! Prag! Wow, what a combination. In this spotlight, we sit down with Karl ...
New

Sub Categories: