Skip to content

Commit

Permalink
adds e2e tests with nightwatch #32
Browse files Browse the repository at this point in the history
  • Loading branch information
jackcarlisle committed Sep 29, 2016
1 parent c177aeb commit 961b5ae
Show file tree
Hide file tree
Showing 11 changed files with 86 additions and 1 deletion.
50 changes: 50 additions & 0 deletions examples/sdk-upload/nightwatch.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
module.exports = {
'src_folders': [
'test/e2e'// Where you are storing your Nightwatch e2e tests
],
'output_folder': './reports', // reports (test outcome) output by nightwatch
'selenium': { // downloaded by selenium-download module
'start_process': true, // tells nightwatch to start/stop the selenium process
'server_path': '../../node_modules/nightwatch/bin/selenium.jar',
'host': '127.0.0.1',
'port': 4444, // standard selenium port
'cli_args': { // chromedriver is downloaded by selenium-download
'webdriver.chrome.driver': '../../node_modules/nightwatch/bin/chromedriver'
}
},
'test_settings': {
'default': {
'screenshots': {
'enabled': true, // if you want to keep screenshots
'path': './screenshots' // save screenshots here
},
'globals': {
'waitForConditionTimeout': 5000 // sometimes internet is slow so wait.
},
'desiredCapabilities': { // use Chrome as the default browser for tests
'browserName': 'chrome'
}
},
'chrome': {
'desiredCapabilities': {
'browserName': 'chrome',
'javascriptEnabled': true // turn off to test progressive enhancement
}
}
}
}

/**
* selenium-download does exactly what it's name suggests;
* downloads (or updates) the version of Selenium (& chromedriver)
* on your localhost where it will be used by Nightwatch.
*/
var BINPATH = '../../node_modules/nightwatch/bin/'
require('fs').stat(BINPATH + 'selenium.jar', function (err, stat) { // got it?
if (err || !stat || stat.size < 1) {
require('selenium-download').ensure(BINPATH, function (error) {
if (error) throw new Error(error) // no point continuing so exit!
console.log('✔ Selenium & Chromedriver downloaded to:', BINPATH)
})
}
})
2 changes: 1 addition & 1 deletion examples/sdk-upload/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ <h1>S3 SDK Upload Demo</h1>
<input class="form-control input-sm" id="fileInput" type="file" name="file" onchange="sdkDemo.saveFile(this.files)"/>
</form>
<br/>
<button class="btn btn-embossed btn-primary" onclick="sdkDemo.submitFile()">Submit</button>
<button class="btn btn-embossed btn-primary" id="submit" onclick="sdkDemo.submitFile()">Submit</button>
<div class="successMessageContainer">
<a class="imageLink"></a>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8" ?>
<testsuites errors="0"
failures="0"
tests="1">

<testsuite name="sdk-upload.test"
errors="0" failures="0" hostname="" id="" package="sdk-upload.test" skipped="0"
tests="1" time="17.38" timestamp="Thu, 29 Sep 2016 16:31:44 GMT">

<testcase name="Image Upload" time="17.38" assertions="3">






</testcase>


</testsuite>
</testsuites>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions examples/sdk-upload/test/e2e/sdk-upload.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module.exports = {
'Image Upload': function (browser) {
browser
.url('http://localhost:8000')
.waitForElementVisible('body', 1000)
.waitForElementVisible('input#fileInput', 1000)
.pause(1000)
.setValue('input#fileInput', require('path').resolve(__dirname + '/another-cute-kitten.jpg'))
.click('#submit')
.pause(13000)
.assert.containsText('h4', 'Image Successfully Uploaded')
.end()
}
}
Empty file.

0 comments on commit 961b5ae

Please sign in to comment.