BDD UI test setup
parent
32aae89c6e
commit
cc21f4b381
@ -0,0 +1 @@
|
||||
client/tests/**/*
|
||||
@ -0,0 +1,6 @@
|
||||
Feature: login
|
||||
|
||||
Scenario: valid user logs in
|
||||
Given user has browsed to the login page
|
||||
When user logs in with username "demo@demo.demo" and password "demo"
|
||||
Then user should be in dashboard page
|
||||
@ -0,0 +1,20 @@
|
||||
const { Given, When, Then } = require('@cucumber/cucumber');
|
||||
const { client } = require('nightwatch-api');
|
||||
|
||||
Given('user has browsed to the login page', function () {
|
||||
return client.url(client.launchUrl + '/login');
|
||||
});
|
||||
|
||||
When(
|
||||
'user logs in with username {string} and password {string}',
|
||||
function (username, password) {
|
||||
return client
|
||||
.setValue('input[name=emailOrUsername]', username)
|
||||
.setValue('input[name=password]', password)
|
||||
.click('.field > button');
|
||||
}
|
||||
);
|
||||
|
||||
Then('user should be in dashboard page', async function () {
|
||||
return client.assert.containsText('.menu > .item:nth-child(3)', 'Demo Demo');
|
||||
});
|
||||
@ -0,0 +1,30 @@
|
||||
const path = require('path');
|
||||
const {
|
||||
setDefaultTimeout,
|
||||
After,
|
||||
Before,
|
||||
AfterAll,
|
||||
BeforeAll,
|
||||
} = require('@cucumber/cucumber');
|
||||
const {
|
||||
createSession,
|
||||
closeSession,
|
||||
startWebDriver,
|
||||
} = require('nightwatch-api');
|
||||
|
||||
startWebDriver({ configFile: path.join(__dirname, 'nightwatch.conf.js') });
|
||||
setDefaultTimeout(60000);
|
||||
|
||||
BeforeAll(async function () {});
|
||||
|
||||
// runs before each scenario
|
||||
Before(async function () {
|
||||
await createSession();
|
||||
});
|
||||
|
||||
// runs after each scenario
|
||||
After(async function () {
|
||||
await closeSession();
|
||||
});
|
||||
|
||||
AfterAll(async function () {});
|
||||
@ -0,0 +1,17 @@
|
||||
const LAUNCH_URL = process.env.LAUNCH_URL || 'http://localhost:3000';
|
||||
|
||||
module.exports = {
|
||||
test_settings: {
|
||||
default: {
|
||||
launch_url: LAUNCH_URL,
|
||||
selenium: {
|
||||
start_process: false,
|
||||
host: 'localhost',
|
||||
port: 4444,
|
||||
},
|
||||
desiredCapabilities: {
|
||||
browserName: 'chrome',
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
Loading…
Reference in New Issue