严格模式testcafe



我有一个使用OAuth的外部登录页面。我想在Testcafe中使用它来运行端到端测试。在正常情况下,我可以登录没有任何问题。没有给出错误。如果我运行testcafe,我得到以下错误:

- Error in Role initializer -
A JavaScript error occurred on ...
Repeat test actions in the browser and check the console for errors.
If you see this error, it means that the tested website caused it. You can fix it or disable tracking JavaScript errors in TestCafe. To do the
latter, enable the "--skip-js-errors" option.
If this error does not occur, please write a new issue at:
"https://github.com/DevExpress/testcafe/issues/new?template=bug-report.md".

JavaScript error details:
SyntaxError: In strict mode code, functions can only be declared at top level or inside a block.
Browser: Chrome 88.0.4324.146 / macOS 10.15.7

跳过错误不是一个解决方案,因为脚本不会加载,我无法登录到网站。

测试如下所示:

export const adminRole = Role(
`https://url of the oauth site`,
async (t) => {
await t
.typeText(Selector('#username'), 'username')
.typeText(Selector('#password'), 'strongpassword')
.click(Selector('#mainButton'));
},
{ preserveUrl: true }
);
fixture('Home page');
test('Show profile page', async (t) => {
await t.useRole(adminRole);
await t.navigateTo('http://tested site/profile');
await waitForAngular();
});

这是一个bug。你可以在Github上了解更多。

相关内容

  • 没有找到相关文章

最新更新