【发布时间】:2019-01-22 09:35:09
【问题描述】:
我正在尝试运行我的第一个 testcafe 测试,但它被证明是艰巨的。
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');
});
我的代码没有任何错误。它编译和工作正常,并通过了我所有的笑话和酶单元测试。但是我在网上找不到任何指导。如您所见,忽略错误标志无济于事。
干杯。
【问题讨论】:
-
你可以尝试使用这个选项作为一个hacky解决方法 - devexpress.github.io/testcafe/documentation/using-testcafe/… 作为另一个想法(从未使用过testcafe tbh),你可以尝试
ReactSelector('<target component>');然后使用这个选择器作为第一个typeText中的参数。如果您搜索typeText,则在github.com/DevExpress/testcafe-react-selectors 进行类似的操作 -
请给我一个链接到您的网页或创建一个类似的在线示例,以便我可以在本地检查问题。
标签: javascript reactjs automated-tests e2e-testing testcafe