Skip to content

Commit

Permalink
Merge branch 'nightwatch'
Browse files Browse the repository at this point in the history
  • Loading branch information
yanick committed Feb 3, 2018
2 parents daff19a + c2dce0e commit 213422b
Show file tree
Hide file tree
Showing 9 changed files with 110 additions and 0 deletions.
1 change: 1 addition & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
## NEXT

* Relative local paths are based on the referring schema, not the original one. [GH#53, Krokop]
* Add Nightwatch.js-based tests.
* README markdown fixes. [GH#57, olleolleolle]

9 changes: 9 additions & 0 deletions lib/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const express = require('express');
const path = require('path');
const app = express();

app.use(express.static('files'))

app.use('/', express.static(path.join(__dirname, '..')) );

module.exports = app;
36 changes: 36 additions & 0 deletions nightwatch.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
module.exports = {
"src_folders" : ["nightwatch"],
"output_folder" : "reports",
"selenium" : {
"start_process" : false,
// "server_path" : "./bin/selenium-server-standalone-3.8.1.jar",
"port" : 4444,
"cli_args" : {
"webdriver.gecko.driver" : "./bin/geckodriver"
}
},

"test_settings" : {
"default" : {
"launch_url" : "http://localhost",
"selenium_port" : 4444,
"selenium_host" : "localhost",
"silent": true,
"screenshots" : {
"enabled" : false,
"path" : ""
},
"desiredCapabilities": {
"browserName": "firefox",
"marionette": true
}
},

"chrome" : {
"desiredCapabilities": {
"browserName": "chrome"
}
}

}
}
16 changes: 16 additions & 0 deletions nightwatch/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Nightwatch tests

## Install

$ npm -g install selenium-standalone
$ selenium-standalone install

## Run

In one console:

$ selenium-standalone start

And in another:

$ nightwatch
23 changes: 23 additions & 0 deletions nightwatch/basic.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const c2x = require( 'css2xpath' );
let static_app = require( '../lib/server' );
let server;

const rootUrl = "http://localhost:3000/index.html";

module.exports = {
before: done => {
server = static_app.listen( 3000, done );
},
after: done => server.close( done ),
'relative paths' : function (browser) {
browser.url( rootUrl + "#tests/relative.json").pause(1000);

browser
.useXpath()
.expect
.element(c2x(':contains("a baz string")'))
.present;

browser.end();
}
};
4 changes: 4 additions & 0 deletions scripts/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
require('../lib/server').listen(
3000,
() => console.log( "server running on port 3000")
);
7 changes: 7 additions & 0 deletions tests/relative.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"$id": "one",
"type": "object",
"properties": {
"foo": { "$ref": "./subdir/bar.json" }
}
}
7 changes: 7 additions & 0 deletions tests/subdir/bar.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"$id": "two",
"type": "object",
"properties": {
"baz": { "$ref": "./baz.json" }
}
}
7 changes: 7 additions & 0 deletions tests/subdir/baz.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"$id": "three",
"type": "object",
"properties": {
"baz": { "type": "string", "description": "a baz string" }
}
}

0 comments on commit 213422b

Please sign in to comment.