create-react-app-typescript icon indicating copy to clipboard operation
create-react-app-typescript copied to clipboard

Consider removing src/setupTests.ts from tsconfig's exclude section

Open gnapse opened this issue 7 years ago • 0 comments

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?

gnapse avatar Jul 26 '18 16:07 gnapse