First commit

This commit is contained in:
2022-02-27 15:37:42 +01:00
commit e474549aad
397 changed files with 151157 additions and 0 deletions

View File

@ -0,0 +1,26 @@
// A custom Nightwatch assertion.
// the name of the method is the filename.
// can be used in tests like this:
//
// browser.assert.elementCount(selector, count)
//
// for how to write custom assertions see
// http://nightwatchjs.org/guide#writing-custom-assertions
exports.assertion = function (selector, count) {
this.message = 'Testing if element <' + selector + '> has count: ' + count
this.expected = count
this.pass = function (val) {
return val === this.expected
}
this.value = function (res) {
return res.value
}
this.command = function (cb) {
var self = this
return this.api.execute(function (selector) {
return document.querySelectorAll(selector).length
}, [selector], function (res) {
cb.call(self, res)
})
}
}

View File

@ -0,0 +1,41 @@
// http://nightwatchjs.org/guide#settings-file
module.exports = {
'src_folders': ['test/e2e/specs'],
'output_folder': 'test/e2e/reports',
'custom_assertions_path': ['test/e2e/custom-assertions'],
'selenium': {
'start_process': true,
'server_path': require('selenium-server').path,
'host': '127.0.0.1',
'port': 4444,
'cli_args': {
'webdriver.chrome.driver': require('chromedriver').path,
'webdriver.geckodriver.driver': require('chromedriver').path
}
},
'test_settings': {
'default': {
'selenium_port': 4444,
'selenium_host': 'localhost',
'silent': true
},
'chrome': {
'desiredCapabilities': {
'browserName': 'chrome',
'javascriptEnabled': true,
'acceptSslCerts': true
}
},
'firefox': {
'desiredCapabilities': {
'browserName': 'firefox',
'javascriptEnabled': true,
'acceptSslCerts': true
}
}
}
}

30
test/e2e/runner.js Normal file
View File

@ -0,0 +1,30 @@
// 1. start the dev server
var server = require('../../build/dev-server.js')
// 2. run the nightwatch test suite against it
// to run in additional browsers:
// 1. add an entry in test/e2e/nightwatch.conf.json under "test_settings"
// 2. add it to the --env flag below
// For more information on Nightwatch's config file, see
// http://nightwatchjs.org/guide#settings-file
var spawn = require('cross-spawn')
var runner = spawn(
'./node_modules/.bin/nightwatch',
[
'--config', 'test/e2e/nightwatch.conf.js',
'--env', 'chrome,firefox'
],
{
stdio: 'inherit'
}
)
runner.on('exit', function (code) {
server.close()
process.exit(code)
})
runner.on('error', function (err) {
server.close()
throw err
})

14
test/e2e/specs/test.js Normal file
View File

@ -0,0 +1,14 @@
// For authoring Nightwatch tests, see
// http://nightwatchjs.org/guide#usage
module.exports = {
'default e2e tests': function (browser) {
browser
.url('http://localhost:8080')
.waitForElementVisible('#app', 5000)
.assert.elementPresent('.logo')
.assert.containsText('h1', 'DASHBOARD Overview of environment')
.assert.elementCount('p', 4)
.end()
}
}