Я пытаюсь написать несколько базовых c e2e тестов с testcafe
в приложении React/Electron
. Сначала я написал базовый c тест для получения приложения. Название страницы:
App.e2e. js
import { Selector } from 'testcafe';
fixture`Electron App`.page('../../app/app.html');
test('should contain expected page title', async browser => {
await browser.expect(getPageTitle()).eql('Electron App');
});
Испытательный тест это работало хорошо!
Но сейчас я пытаюсь добавить другие тесты, например, попытаться войти в приложение с помощью следующего примера:
App.e2e. js
import { Selector, Role } from 'testcafe';
const UserRole = Role('../../app/app.html', async t => {
await t
.typeText('input[name="email"]', 'user@user.com')
.typeText('input[name="password"]', 'secret')
.click(Selector('button[type=submit]').withText('Login'));
});
fixture`Electron App`
.page('../../app/app.html')
.beforeEach(async t => {
await t.useRole(UserRole);
});
test('Click a doc', async t => {
await t
.click(Selector('span').withText('Document'))
.expect(Selector('h1').withText('Document').exists)
.ok();
});
Когда я пытаюсь запустить e2e
тесты, я получаю странную ошибку, подобную этой:
Вывод на консоль
ERROR Cannot prepare tests due to an error.
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined
at resolveFileUrl (C:\Users\user\Git\electronApp\node_modules\testcafe\src\api\test-page-url.js:20:30)
at Object.resolvePageUrl (C:\Users\user\Git\electronApp\node_modules\testcafe\src\api\test-page-url.js:42:16)
at Proxy.createRole (C:\Users\user\Git\electronApp\node_modules\testcafe\src\role\index.js:73:17)
at Role (C:\Users\user\Git\electronApp\node_modules\testcafe\src\api\exportable-lib\index.js:15:17)
at Object.<anonymous> (C:\Users\user\Git\electronApp\tests\e2e\App.e2e.js:8:18)
at Function._execAsModule (C:\Users\user\Git\electronApp\node_modules\testcafe\src\compiler\test-file\api-based.js:50:13)
at ESNextTestFileCompiler._runCompiledCode (C:\Users\user\Git\electronApp\node_modules\testcafe\src\compiler\test-file\api-based.js:150:42)
at ESNextTestFileCompiler.execute (C:\Users\user\Git\electronApp\node_modules\testcafe\src\compiler\test-file\api-based.js:174:21)
at ESNextTestFileCompiler.compile (C:\Users\user\Git\electronApp\node_modules\testcafe\src\compiler\test-file\api-based.js:180:21)
at Compiler._getTests (C:\Users\user\Git\electronApp\node_modules\testcafe\src\compiler\index.js:86:31)
Type "testcafe -h" for help.
error Command failed with exit code 1.
Кажется, что testcafe не может найти правильный path
для запуска приложения электронов, но в первом случае тест работал по той же схеме. Я что-то упускаю?