lundi 3 juillet 2017

Control vue navigation from Testcafe

For testing Vue2 I use testcafe. Command to run tests

testcafe firefox test/e2e/specs/ --app \"npm run dev\"
--app-init-delay 20000 -S -s test/e2e/screenshots

Test file

import { ClientFunction, Selector } from 'testcafe';
const devServer = require('../../../webpack/devServer');

fixture(`Getting Started`)
// Load the URL your development server runs on.
    .page(`http://localhost:${devServer.port}/#/login`);

test('test login', async t => {
    const userSelector = await new Selector('.login-squere input[type="text"]');
    const passSelector = await new Selector('.login-squere input[type="password"]');
    const logiIn = await new Selector('.login-squere button');
    await t.typeText(userSelector, 'manager')
        .typeText(passSelector, 'manager')
        .click(logiIn);
});

I expect after .click(logiIn) site to route to /#/projects, but nothing happens I added to test

await t.typeText(userSelector, 'manager')
        .typeText(passSelector, 'manager')
        .click(logiIn)
        .navigateTo(`http://localhost:${devServer.port}/#/projects`);

And again no result. If I set .page to /#/projects it wil be rerouted to login.

So I can test only login page, because I cant make testcafe route Vue to next view.

Aucun commentaire:

Enregistrer un commentaire