I'm trying to run my first testcafe test but it's proving arduous.
testcafe -e chrome client/routes/Lookup/components/testcafe/lookup-test.js
SyntaxError: client/routes/Lookup/components/Lookup.js: Unexpected token (60:8)
58 | if (error.status && error.status !== 404) {
59 | return (
> 60 | <NetworkIssues code={error.status} />
| ^
61 | );
62 | }
63 |
at Object.<anonymous> (client/routes/Lookup/components/testcafe/lookup-test.js:1:1)
lookup-test.js
import Lookup from '../Lookup';
import React from 'react';
import { waitForReact } from 'testcafe-react-selectors';
fixture('Lookup Component').page('http://localhost:3000/web/lookup').beforeEach(async () => {
await waitForReact();
});
test('foo', async (x) => {
await x
.typeText('customerName', '07450118811')
.expect('customerName.value').contains('07450118811');
});
My code doesn't have any errors. It compiles and works fine and passes all my jest and enzyme unit testing. But I can't find any guidance online for this. As you can see the ignore errors flag is used to no avail.
Cheers.
When you start TestCafe, all your test code is transpiled as a first step before execution. What is executed is the result of this transpilation process and not your original source code, even if your code is pure JavaScript.
The imported file client/routes/Lookup/components/Lookup.js
is a JSX file, and since it is imported in the TestCafe code, il will be first transpiled to javascript before starting test execution.
The TestCafe transpilation process (at the time of writing - it may change in the future) is not configured to handle JSX files.
Therefore, you cannot import files that cannot be transpiled into pure JS by TestCafe.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With