jest-styled-components icon indicating copy to clipboard operation
jest-styled-components copied to clipboard

Global installation section is outdated

Open Cmac2712 opened this issue 7 years ago • 2 comments

It appears the "setupTestFrameworkScriptFile" option for Jest configuration is now deprecated in favor of "setupFilesAfterEnv"

https://jestjs.io/docs/en/configuration.html#setupfilesafterenv-array

Cmac2712 avatar Mar 08 '19 11:03 Cmac2712

I second this, and can maybe roll out a PR to update?

https://github.com/styled-components/jest-styled-components#global-installation

It might also useful to include the common version of the import for CRA users.

nicolechung avatar Jun 30 '19 17:06 nicolechung

Hello, I would suggest leaving both options available. In case the user is not setting any other package the setupTests.js file is not needed. I propose something like this:

Global installation

It is possible to setup this package for all the tests.

Using setupTests.js file (recommended for CRA)

Import the library once in the src/setupTests.js as follows:

import 'jest-styled-components'

Configuration Option

Include 'jest-styled-components' in the setupFilesAfterEnv option. Example setupFilesAfterEnv array in a jest.config.js:

module.exports = {
  setupFilesAfterEnv: ['jest-styled-components'],
};

update: an example here https://github.com/wachunei/directUC/pull/122/files

wachunei avatar Oct 20 '20 20:10 wachunei