Full-Stack Web Development with Vue.js and Node

(singke) #1
Testing an MEVN Application Chapter 9

We have added the necessary identifier to all of the components. Now, let's add the e2e


tests for the previously mentioned scenarios.


Replace the contents of test/e2e/specs/test.js with the following code:


// For authoring Nightwatch tests, see
// http://nightwatchjs.org/guide#usage

module.exports = {
'default e2e tests': function test(browser) {
// automatically uses dev Server port from /config.index.js
// default: http://localhost:8080
// see nightwatch.conf.js
const devServer = browser.globals.devServerURL;
console.log(devServer)

browser
.url(devServer)
.waitForElementVisible('#inspire', 9000)
.assert.elementPresent('.list')
.assert.elementPresent('.list .side_bar_link')
.assert.elementPresent('.side_bar_link #home')
.assert.elementPresent('.side_bar_link #contact')
.click('#drawer')
.pause(1000)
.click('#contact')
.pause(1000)
.assert.elementPresent('#inspire .contact')
.assert.containsText('#inspire .contact h1', 'this is contact')
.pause(1000)
.click('#login_btn')
.pause(1000)
.assert.elementCount('input', 2)
.setValue('input#email', '[email protected]')
.setValue('input#password', 'secret')
.pause(1000)
.click('#login')
.pause(1000)
.click('.swal-button--confirm')
.pause(1000)
.assert.containsText('#user_email', '[email protected]')
.click('#add_movie_link')
.pause(2000)
.assert.elementCount('input', 3)
.assert.elementCount('textarea', 1)
.setValue('input#name', 'Avengers: Infinity War')
.setValue('textarea#description', 'Iron Man, Thor, the Hulk and the
Free download pdf