Testing 使用testcafe体验超慢速测试

Testing 使用testcafe体验超慢速测试,testing,automated-tests,e2e-testing,web-testing,testcafe,Testing,Automated Tests,E2e Testing,Web Testing,Testcafe,我目前第一次尝试testcafe,我以这门课程为例,我面临着非常缓慢的测试 例如,testcafe e2e/login.test.js,它基本上是一个寄存器,登录有时需要6分钟才能通过,与作者在课程中的15秒相比,我发现速度慢得惊人 import {Selector} from 'testcafe'; const randomstring = require('randomstring'); const username = randomstring.generate(); const ema

我目前第一次尝试testcafe,我以这门课程为例,我面临着非常缓慢的测试

例如,
testcafe e2e/login.test.js
,它基本上是一个寄存器,登录有时需要6分钟才能通过,与作者在课程中的15秒相比,我发现速度慢得惊人

import {Selector} from 'testcafe';

const randomstring = require('randomstring');
const username = randomstring.generate();
const email = `${username}@test.com`;
const TEST_URL = process.env.TEST_URL;
fixture('/login').page(`${TEST_URL}/login`);


test(`should display the sign-in form`, async (t) => {
    await t
        .navigateTo(`${TEST_URL}/login`)
        .expect(Selector('H1').withText('Login').exists).ok()
        .expect(Selector('form').exists).ok()
});

test(`should allow a user to sign in`, async (t) => {
// register user
    await t
        .navigateTo(`${TEST_URL}/register`)
        .typeText('input[name="username"]', username)
        .typeText('input[name="email"]', email)
        .typeText('input[name="password"]', 'test')
        .click(Selector('input[type="submit"]'))
// log a user out
    await t
        .click(Selector('a').withText('Log Out'))
// log a user in
    await t
        .navigateTo(`${TEST_URL}/login`)
        .typeText('input[name="email"]', email)
        .typeText('input[name="password"]', 'test')
        .click(Selector('input[type="submit"]'))
// assert user is redirected to '/'
// assert '/' is displayed properly
    const tableRow = Selector('td').withText(username).parent();
    await t
        .expect(Selector('H1').withText('All Users').exists).ok()
        .expect(tableRow.child().withText(username).exists).ok()
        .expect(tableRow.child().withText(email).exists).ok()
        .expect(Selector('a').withText('User Status').exists).ok()
        .expect(Selector('a').withText('Log Out').exists).ok()
        .expect(Selector('a').withText('Register').exists).notOk()
        .expect(Selector('a').withText('Log In').exists).notOk()
// log a user out
    await t
        .click(Selector('a').withText('Log Out'))
// assert '/logout' is displayed properly
    await t
        .expect(Selector('p').withText('You are now logged out').exists).ok()
        .expect(Selector('a').withText('User Status').exists).notOk()
        .expect(Selector('a').withText('Log Out').exists).notOk()
        .expect(Selector('a').withText('Register').exists).ok()
        .expect(Selector('a').withText('Log In').exists).ok()
});
我尝试了Firefox,同样的交易,尽管速度要快得多,44秒

(project-tOIAx_A8) ➜  testdriven-app git:(master) ✗ testcafe 'chromium' e2e/login.test.js        
Using locally installed version of TestCafe.
(node:16048) ExperimentalWarning: The fs.promises API is experimental
 Running tests in:
 - Chrome 67.0.3396 / Linux 0.0.0

 /login
 ✓ should display the sign in form
 ✓ should allow a user to sign in


 2 passed (6m 15s)
我希望我能提供更多信息,访问开发工具,检查控制台,但没有注意到任何错误消息,有时除了以下错误消息:

hammerhead.js:7 WebSocket connection to 'ws://192.168.1.195:38039/4wxhbvTF7!w!http%3A%2F%2F172.18.0.5/http://172.18.0.5/sockjs-node/444/2kjm15kn/websocket' failed: Error during WebSocket handshake: Unexpected response code: 400
,瀑布看起来很慢,有没有办法提供一个日志报告来帮助了解这种缓慢的情况

编辑:我在测试开始和结束时放置了一个.debug(),如果有帮助的话,保存一个

编辑2:这是一个如果有帮助的话


根据您的Chrome日志,XHR请求会在超时时停止。据我所知,您的服务器可以在本地或亚马逊上运行。在第一种情况下,您可以定义“-hostname localhost”参数并使用“localhost”作为测试URL。在Amazon的情况下,尝试使用本地服务器和VPN来检查测试如何通过VPN运行。我的应用程序在docker容器中运行,我在运行testcafe之前导出TEST_URL,它指向我的nginx容器,该容器提供React应用程序,这可能是问题的根源吗?请上载您的容器(-s)到Docker Hub,以便我在本地检查它或共享代码的某些部分?此外,请澄清您正在使用的操作系统,并提供“docker machine ls”命令输出。