I have implemented detox for my react native app.I created dashboard.test.tsx
to run my first tests. Below you can see a sample test I wrote in that file.
import { device } from 'detox';import { Dashboard } from '../app/screens/Dashboard';import { render } from '@testing-library/react-native';describe('First tests', () => { beforeAll(async () => { await device.launchApp({ newInstance: true, permissions: { notifications: 'YES' } }); }); beforeEach(async () => { await device.reloadReactNative(); it('should be able to test dasboard screen', async () => { render(<Dashboard/>);});
When I try to run the test file I get the below error.
(0, react_native_1.render)(<Dashboard_1.Dashboard />);SyntaxError: Unexpected token '<'at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1598:14)
This is my jest.config.js
file inside e2e folder
/** @type {import('@jest/types').Config.InitialOptions} */module.exports = { preset: 'ts-jest', testEnvironment: 'node', transform: {'^.+\\.ts?$': 'ts-jest','^.+\\.tsx?$': 'ts-jest', }, transformIgnorePatterns: ['<rootDir>/node_modules/'], rootDir: '..', testMatch: ['<rootDir>/e2e/**/*.test.tsx'], testTimeout: 120000, maxWorkers: 1, globalSetup: 'detox/runners/jest/globalSetup', globalTeardown: 'detox/runners/jest/globalTeardown', reporters: ['detox/runners/jest/reporter'], testEnvironment: 'detox/runners/jest/testEnvironment', verbose: true,};
This is the jest.config.js
file in the root folder
module.exports = { preset: 'react-native', moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node']};
React-native: 0.64.2
detox: 20.1.2
jest: 29.4.1
Anyone have any idea how to solve this?