This repository was archived by the owner on Mar 5, 2022. It is now read-only.

Description
Example error:
Error: Webpack Compilation Error
./cypress/component/App.test.tsx 7:10
Module parse failed: Unexpected token (7:10)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| describe('HelloWorld component', () => {
| it('works', () => {
> mount(<App />);
| // use standard Cypress commands
| cy.contains('learn react').should('be.visible');
@ multi ./cypress/component/App.test.tsx main[0]
Setup
npx create-react-app my-app --template typescript
cd my-app
npm i cypress cypress-react-unit-test
{
"experimentalComponentTesting": true
}
module.exports = (on, config) => {
require('cypress-react-unit-test/plugins/react-scripts')(on, config)
return config
}
- cypress/component/App.test.tsx
import React from 'react';
import { mount } from 'cypress-react-unit-test'
import App from '../../src/App';
describe('HelloWorld component', () => {
it('works', () => {
mount(<App />);
// use standard Cypress commands
cy.contains('learn react').should('be.visible');
});
});
- Now run
npx cypress open and select the component test App.test.tsx. You will see the error as shown:

The default zero config cypress support for TypeScript in integration tests is lovely and would like the same for component tests 🌹