Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jest-enzyme: docs: installing jest-enzyme and its type defs #350

Open
espretto opened this issue Sep 18, 2020 · 1 comment
Open

jest-enzyme: docs: installing jest-enzyme and its type defs #350

espretto opened this issue Sep 18, 2020 · 1 comment

Comments

@espretto
Copy link

espretto commented Sep 18, 2020

Hello,
the readme currently has two split sections on installing jest-enzyme: one at the top for general import and another at the bottom for cra and ts specifics. I'd like to put them under a common headline and make the following changes:

1/ The alternative setup suggests to specify jest-enzyme's main module path. Would the following work, too?

// package.json
"jest": {
+  "setupFilesAfterEnv": ['jest-enzyme'],
-  "setupFilesAfterEnv": ['./node_modules/jest-enzyme/lib/index.js'],
}

2/ The instructions for Typescript suggest to import jest-enzyme from src/setupTests.js to ensure the signatures are available to the language-server. Alternatively, that import can be made from a .d.ts-file to be included in the tsconfig's typeRoots option. Example src/types/jest-enzyme.d.ts:

import 'jest-enzyme';

Example tsconfig.json

{
  "compilerOptions": {
    "typeRoots": ["./src/types/"]
  }
}

3/ Some links are obsolete. CRA docs on tests moved here

@s-weigand
Copy link

Thanks to you issue I finally got my tests running with ts-jest 😄
I added "typeRoots": ["./node_modules/@types","./node_modules/jest-enzyme/lib"] to my compilerOptions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants