I've started a Create React App project with --typescript. When I write a test Im getting a compiler error:
// something-test.tsx
test('something', ()=>{
expect(1).toBe(1)
})
The error is:
TS1208: All files must be modules when the '--isolatedModules' flag is provided.
From googling I thought the fix was to create a jest.config.tsx with:
module.exports = {
roots: ["<rootDir>/src"],
transform: {
"^.+\\.tsx?$": "ts-jest"
},
testRegex: "(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$",
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"]
};
However it's made no difference.