严格的时尚测试咖啡馆

Strict mode testcafe

我有一个使用 OAuth 的外部登录页面。我想将它与 Testcafe 一起用于 运行ning e2e 测试。在正常情况下,我可以毫无问题地登录。没有给出错误。如果我 运行 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();
});

这是一个错误。你可以 catch up on Github.