испытывает супер медленные тесты с testcafe - PullRequest
0 голосов
/ 01 июля 2018

В настоящее время я впервые экспериментирую с testcafe, в качестве примера я использую курс testdriven.io и сталкиваюсь с очень медленными тестами.

Например, 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

, водопад выглядит медленно, есть ли способ сделать отчет о нем, чтобы помочь понять, в каких случаях это замедление?

edit: я помещаю .debug () в начале и в конце тестов и сохраняю профиль производительности внутри Firefox , если это помогает

edit2: это профиль производительности в хроме , если это помогает

enter image description here

...