create-react-app-typescript
create-react-app-typescript copied to clipboard
Consider removing src/setupTests.ts from tsconfig's exclude section
Is this a bug report?
No
What's the question then?
I wonder why src/setupTests.ts is excluded in tsconfig.json. The thing is, when extending jest with custom matchers that are injected into expect's return type, this needs an adjustment making the corresponding extension to jest's expect's return type definition.
Extending jest's extend is usually needed to be done only once, and therefore is usually recommended to be done in the setup tests file. But with this file not included by TS, uses of the custom matchers are flagged as type errors.
See gnapse/jest-dom#45 for details. The solution there in the end was to remove src/setupTests.ts file from the exclude section of tsconfig.json. I wonder if that could be made the default for newly created apps using this TS CRA. And if not, why? And what other solution would be recommended?