I have this role:
import { Role } from 'testcafe';
export default Role('http://localhost:8080/login', async t => {
await t
.setNativeDialogHandler(() => true)
.typeText('#identification', 'test.user@foo.io')
.typeText('#password', 'mypassword')
.click('button[type=submit]');
});
And this test:
import { Selector } from 'testcafe';
import UserRole from '../roles/userRole';
fixture `Visit Dashboard`
.page `http://localhost:8080/dashboards/activity`
.beforeEach(async t => {
await t.useRole(UserRole);
});
test('Dashboard Renders and has two tabs', async t => {
await t.expect(Selector('.dashboard-navigation li').count).eql(2);
});
test('Dashboard Renders and Activity Tab is active', async t => {
const activeTab = Selector('.dashboard-navigation li.active');
await t
.expect(activeTab.count).eql(1)
.expect(activeTab.find('a').innerText).eql('ACTIVITY')
});
Is this the right way to do that?
It definitely logs me in, correctly. But then it goes BACK TO /login for the 2nd test.
This doesn't hurt anything, but slows things down.
Just wondering what the best way is to be able to login before a test (or a giant suite of tests) ONE TIME and then not have it involved over and over again 