如何等待加载时间较长的页面加载testcafe?

Vit*_*man 1 automated-tests e2e-testing testcafe next.js

从这些文档:https: //devexpress.github.io/testcafe/documentation/test-api/actions/navigate.html

看起来我们只能等待15秒才能加载页面.

我们开发了一个NextJS应用程序,它的首次加载需要40秒,因为它在第一次加载时构建应用程序.

我似乎无法使TestCafe在初始页面加载时没有超时.

我试过了

fixture('Restaurant List')
  .page('http://localhost:3000/something')
  .beforeEach(async () => {
    await waitForReact(120000);
  });
Run Code Online (Sandbox Code Playgroud)

例如没有成功.

mlo*_*sev 5

您可以发送启动应用程序构建过程的第一个请求,并仅在收到响应时运行测试.

请参阅下面的代码示例:

const rp             = require('request-promise');
const createTestCafe = require('testcafe');
rp('https://site-url')
    .then(() => {       
         return createTestCafe('localhost', 1337, 1338);
    })   
    .then(testcafe => {
         runner = testcafe.createRunner();

         return runner
             .src('tests');
             .browsers('chrome');
    })
    .catch(err => console.log(err));
Run Code Online (Sandbox Code Playgroud)