From 27f1ed0db14f16794a7eb6368b75533b364bc806 Mon Sep 17 00:00:00 2001 From: Dylan Frankland Date: Sat, 24 Mar 2018 11:33:59 -0700 Subject: [PATCH 1/2] Update README.md (fixes #125) Added an FAQ section that outlines why Jest Styled Components might not be working. --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index ebcac49..5e135ff 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,7 @@ Table of Contents * [Preact](#preact) * [toHaveStyleRule](#tohavestylerule) * [Global installation](#global-installation) + * [FAQ](#faq) * [Contributing](#contributing) # Snapshot Testing @@ -369,6 +370,14 @@ And import the library once in the `setupTest.js` as follows: import 'jest-styled-components' ``` +# FAQ + +### Why is Jest Styled Components not working? + +Jest Styled Components may not work for several reasons, but most likely the problem is caused by loading multiple instances of `styled-components`. Starting with `styled-components@3.2.0`, a warning will be logged when multiple instances of it are being included and run as part of the Jest tests. Using `styled-components@3.1.6` and lower with multiple instances will cause a silent error with unexpected results. + +To debug and fix multiple instances of `styled-components` see the FAQ on ["Why am I getting a warning about several instances of module on the page?"](https://www.styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-several-instances-of-module-on-the-page). + # Contributing Please [open an issue](https://github.com/styled-components/jest-styled-components/issues/new) and discuss with us before submitting a PR. From 40c1d7ea252f802d212b3349833cf9cf6bec1781 Mon Sep 17 00:00:00 2001 From: Dylan Frankland Date: Sun, 25 Mar 2018 11:36:08 -0700 Subject: [PATCH 2/2] Update README.md (fixes #125) --- README.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 5e135ff..fbdc6f9 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ Table of Contents * [Preact](#preact) * [toHaveStyleRule](#tohavestylerule) * [Global installation](#global-installation) - * [FAQ](#faq) + * [Working with multiple packages](#working-with-multiple-packages) * [Contributing](#contributing) # Snapshot Testing @@ -370,11 +370,9 @@ And import the library once in the `setupTest.js` as follows: import 'jest-styled-components' ``` -# FAQ +# Working with multiple packages -### Why is Jest Styled Components not working? - -Jest Styled Components may not work for several reasons, but most likely the problem is caused by loading multiple instances of `styled-components`. Starting with `styled-components@3.2.0`, a warning will be logged when multiple instances of it are being included and run as part of the Jest tests. Using `styled-components@3.1.6` and lower with multiple instances will cause a silent error with unexpected results. +If Jest Styled Components is not working, it is likely caused by loading multiple instances of `styled-components`. This can happen especially when working with a Lerna monorepo. Starting with `styled-components@3.2.0`, a warning will be logged when multiple instances of it are being included and run as part of the Jest tests. Using `styled-components@3.1.6` and lower with multiple instances will cause a silent error with unexpected results. To debug and fix multiple instances of `styled-components` see the FAQ on ["Why am I getting a warning about several instances of module on the page?"](https://www.styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-several-instances-of-module-on-the-page).