a little stuck on this one. I'm introducing react unit testing into my teams node/react project. We've had jest unit tests for our backend and utils in FE for a long time but no react testing.
I'm following the testing guide via https://redux.js.org/recipes/writing-tests
My issue is that, I've created the test file the exact same way all our other unit tests are created and running properly. I've put a fake test case in the file:
import React from 'react';
//import { render } from '@testing-library/react';
describe('test', () => {
it('tests', () => {
expect(true).toEqual(true);
});
});
And this test case executes as expected. However, as soon as I uncomment the import { render } line, it's breaking on the following error:
FAIL */__tests__/client/views/components/componentToTest.test.jsx
● Test suite failed to run
*/node_modules/@testing-library/dom/dist/helpers.js:44
} catch {// not using Jest's modern fake timers
^
SyntaxError: Unexpected token {
at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/script_transformer.js:316:17)
at Object.<anonymous> (node_modules/@testing-library/dom/dist/pretty-dom.js:13:16)
at Object.<anonymous> (node_modules/@testing-library/dom/dist/config.js:11:18)
At a total loss for what's going on here, can't find anyone w/ a similar issue. My IDE even correctly shows me what the render method looks like, so I know its importing properly.
I've installed all of the packages suggested in the guide, and obviously have jest config'd to run jsx files (since the test works, but just breaks on the import)
An answer would be great, but really would love to just be pointed in the right direction of how to resolve this as well.
Thanks!
Also worth noting, I have babel-jest and jest-dom setup, as I know thats the answer to a lot of similar issues.