refactor: new project structure
This commit is contained in:
@@ -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)
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
require('babel-register')
|
||||
var config = require('../../config')
|
||||
|
||||
// http://nightwatchjs.org/gettingstarted#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
|
||||
}
|
||||
},
|
||||
|
||||
test_settings: {
|
||||
default: {
|
||||
selenium_port: 4444,
|
||||
selenium_host: 'localhost',
|
||||
silent: true,
|
||||
globals: {
|
||||
devServerURL: 'http://localhost:' + (process.env.PORT || config.dev.port)
|
||||
}
|
||||
},
|
||||
|
||||
chrome: {
|
||||
desiredCapabilities: {
|
||||
browserName: 'chrome',
|
||||
javascriptEnabled: true,
|
||||
acceptSslCerts: true
|
||||
}
|
||||
},
|
||||
|
||||
firefox: {
|
||||
desiredCapabilities: {
|
||||
browserName: 'firefox',
|
||||
javascriptEnabled: true,
|
||||
acceptSslCerts: true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// 1. start the dev server using production config
|
||||
process.env.NODE_ENV = 'testing'
|
||||
var server = require('../../build/dev-server.js')
|
||||
|
||||
server.ready.then(() => {
|
||||
// 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
|
||||
// or override the environment flag, for example: `npm run e2e -- --env chrome,firefox`
|
||||
// For more information on Nightwatch's config file, see
|
||||
// http://nightwatchjs.org/guide#settings-file
|
||||
var opts = process.argv.slice(2)
|
||||
if (opts.indexOf('--config') === -1) {
|
||||
opts = opts.concat(['--config', 'test/e2e/nightwatch.conf.js'])
|
||||
}
|
||||
if (opts.indexOf('--env') === -1) {
|
||||
opts = opts.concat(['--env', 'chrome'])
|
||||
}
|
||||
|
||||
var spawn = require('cross-spawn')
|
||||
var runner = spawn('./node_modules/.bin/nightwatch', opts, { stdio: 'inherit' })
|
||||
|
||||
runner.on('exit', function (code) {
|
||||
server.close()
|
||||
process.exit(code)
|
||||
})
|
||||
|
||||
runner.on('error', function (err) {
|
||||
server.close()
|
||||
throw err
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,82 @@
|
||||
// For authoring Nightwatch tests, see
|
||||
// http://nightwatchjs.org/guide#usage
|
||||
|
||||
module.exports = {
|
||||
|
||||
before : function(browser) {
|
||||
console.log('Setting up...');
|
||||
},
|
||||
|
||||
after : function(browser) {
|
||||
console.log('Closing down...');
|
||||
},
|
||||
|
||||
'CoreUI Vue e2e tests': function (browser) {
|
||||
// automatically uses dev Server port from /config.index.js
|
||||
// default: http://localhost:8080
|
||||
// see nightwatch.conf.js
|
||||
|
||||
const devServer = browser.globals.devServerURL;
|
||||
|
||||
browser
|
||||
.url(devServer)
|
||||
.pause(500)
|
||||
.expect.element('body').to.be.present;
|
||||
|
||||
browser.waitForElementVisible('.app > .app', 3000)
|
||||
.assert.elementPresent('.app-header')
|
||||
.assert.elementPresent('.app-header > .navbar-brand')
|
||||
.assert.elementPresent('.app-body')
|
||||
.assert.elementPresent('.app-body > .main > .breadcrumb')
|
||||
.assert.elementPresent('.app-body > .main > .container-fluid > .animated')
|
||||
.assert.elementPresent('.app-body > .sidebar > .sidebar-nav')
|
||||
.assert.elementPresent('.app-body > .sidebar > .sidebar-minimizer')
|
||||
.assert.elementPresent('.app-footer')
|
||||
.assert.containsText('.app-footer > span', 'creativeLabs')
|
||||
.assert.containsText('.app-footer > span.ml-auto', 'Powered by')
|
||||
.assert.elementCount('button', 18)
|
||||
.resizeWindow(1024, 800)
|
||||
.pause(500);
|
||||
|
||||
browser.click('body > div > header > button.navbar-toggler.aside-menu-toggler.d-md-down-none', function(response) {
|
||||
this.assert.ok(browser === this, 'Check if the context is right.');
|
||||
this.assert.cssClassNotPresent('body', 'aside-menu-hidden');
|
||||
});
|
||||
|
||||
browser.pause(500);
|
||||
|
||||
browser.click('body > div > header > button.navbar-toggler.aside-menu-toggler.d-md-down-none', function(response) {
|
||||
this.assert.cssClassPresent('body', 'aside-menu-hidden');
|
||||
});
|
||||
|
||||
browser.pause(500);
|
||||
|
||||
browser
|
||||
.useXpath()
|
||||
.click('/html/body/div/header/button[2]', function(response) {
|
||||
this.assert.cssClassPresent('/html/body', 'sidebar-hidden');
|
||||
});
|
||||
|
||||
browser
|
||||
.pause(500)
|
||||
.click('/html/body/div/header/button[2]', function(response) {
|
||||
this.assert.cssClassNotPresent('/html/body', 'sidebar-hidden');
|
||||
});
|
||||
|
||||
browser
|
||||
.pause(500)
|
||||
.click('/html/body/div/div/div/button', function(response) {
|
||||
this.assert.cssClassPresent('/html/body', 'sidebar-minimized');
|
||||
this.assert.cssClassPresent('/html/body', 'brand-minimized');
|
||||
})
|
||||
.pause(500)
|
||||
.click('/html/body/div/div/div/button', function(response) {
|
||||
this.assert.cssClassNotPresent('/html/body', 'sidebar-minimized');
|
||||
this.assert.cssClassNotPresent('/html/body', 'brand-minimized');
|
||||
});
|
||||
|
||||
browser
|
||||
.pause(3000)
|
||||
.end();
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user