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

jon
Some minor things in the paper edition that says “3 2020” on the title page verso, not mentioned in the book’s errata online: p. 186 But...
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
raul
Hi Travis! Thank you for the cool book! :slight_smile: I made a list of issues and thought I could post them chapter by chapter. I’m rev...
New
adamwoolhether
When trying to generate the protobuf .go file, I receive this error: Unknown flag: --go_opt libprotoc 3.12.3 MacOS 11.3.1 Googling ...
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
brunogirin
When trying to run tox in parallel as explained on page 151, I got the following error: tox: error: argument -p/–parallel: expected one...
New
s2k
Hi all, currently I wonder how the Tailwind colours work (or don’t work). For example, in app/views/layouts/application.html.erb I have...
New
Keton
When running the program in chapter 8, “Implementing Combat”, the printout Health before attack was never printed so I assumed something ...
New
davetron5000
Hello faithful readers! If you have tried to follow along in the book, you are asked to start up the dev environment via dx/build and ar...
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

Devtalk
Reading something? Working on something? Planning something? Changing jobs even!? If you’re up for sharing, please let us know what you’...
1032 17402 381
New
ohm
Which, if any, games do you play? On what platform? I just bought (and completed) Minecraft Dungeons for my Nintendo Switch. Other than ...
New
AstonJ
You might be thinking we should just ask who’s not using VSCode :joy: however there are some new additions in the space that might give V...
New
AstonJ
poll poll Be sure to check out @Dusty’s article posted here: An Introduction to Alternative Keyboard Layouts It’s one of the best write-...
New
PragmaticBookshelf
Rust is an exciting new programming language combining the power of C with memory safety, fearless concurrency, and productivity boosters...
New
AstonJ
Do the test and post your score :nerd_face: :keyboard: If possible, please add info such as the keyboard you’re using, the layout (Qw...
New
PragmaticBookshelf
Learn different ways of writing concurrent code in Elixir and increase your application's performance, without sacrificing scalability or...
New
mafinar
Crystal recently reached version 1. I had been following it for awhile but never got to really learn it. Most languages I picked up out o...
New
PragmaticBookshelf
Author Spotlight: Karl Stolley @karlstolley Logic! Rhetoric! Prag! Wow, what a combination. In this spotlight, we sit down with Karl ...
New
sir.laksmana_wenk
I’m able to do the “artistic” part of game-development; character designing/modeling, music, environment modeling, etc. However, I don’t...
New

Sub Categories: