For initial project set up click here. Delete this line afterwards
- overview of project goes here example...
- Modern features brought to IRC. Push notifications, link previews, new message markers, and more bring IRC to the 21st century.
- Always connected. Remains connected to IRC servers while you are offline.
- Cross platform. It doesn't matter what OS you use, it just works wherever Node.js runs.
- Responsive interface. The client works smoothly on every desktop, smartphone and tablet.
- Synchronized experience. Always resume where you left off no matter what device.
npm install
npm test
npx nightwatch tests/nightwatch/example.js
- running and stable releases info goes here
The following commands install and run the development version of:
* git commands goes here
Simply follow the instructions to run The project from source above, on your own fork.
npm install --save-dev mocha
npm i --save-dev chai
var assert = require('assert');
describe('Array', function() {
describe('#indexOf()', function() {
it('should return -1 when the value is not present', function() {
assert.equal([1, 2, 3].indexOf(4), -1);
});
});
});
"scripts": {
"test": "mocha"
}
npm test
describe('string name', function(){
// can nest more describe()'s here, or tests go here
});
it('should...', function(){
// Test case goes here
});
Expect style:var assert = require('chai').assert; var numbers = [1, 2, 3, 4, 5];
assert.isArray(numbers, 'is array of numbers'); assert.include(numbers, 2, 'array contains 2'); assert.lengthOf(numbers, 5, 'array contains 5 numbers');
var expect = require('chai').expect;
var numbers = [1, 2, 3, 4, 5];
expect(numbers).to.be.an('array').that.includes(2);
expect(numbers).to.have.lengthOf(5);
Should style:
var should = require('chai').should();
var numbers = [1, 2, 3, 4, 5];
numbers.should.be.an('array').that.includes(2);
numbers.should.have.lengthOf(5);
// Require the built in 'assertion' library
var assert = require('assert');
// Create a group of tests about Arrays
describe('Array', function() {
// Within our Array group, Create a group of tests for indexOf
describe('#indexOf()', function() {
// A string explanation of what we're testing
it('should return -1 when the value is not present', function(){
// Our actual test: -1 should equal indexOf(...)
assert.equal(-1, [1,2,3].indexOf(4));
});
});
});
npm install nightwatch geckodriver chromedriver --save-dev
Test successfull installation by running:
npx nightwatch node_modules/nightwatch/examples/tests/ecosia.js
Global
nightwatch [source] [options]
npx nightwatch [source] [options]
nightwatch tests/one/firstTest.js
nightwatch tests/one/firstTest.js tests/secondTest.js
nightwatch tests/one/test.js tests/utils
Test Example:
module.exports = {
'Demo test Google' : function (client) {
client
.url('http://www.google.com')
.waitForElementVisible('body', 1000)
.assert.title('Google')
.assert.visible('input[type=text]')
.setValue('input[type=text]', 'rembrandt van rijn')
.waitForElementVisible('button[name=btnG]', 1000)
.click('button[name=btnG]')
.pause(1000)
.assert.containsText('ol#rso li:first-child',
'Rembrandt - Wikipedia')
.end()
}
}
assert[.not].attributeContains()
this.demoTest = function (browser) {
browser.assert.attributeContains('#someElement', 'href', 'google.com');
};
this.demoTest = function (browser) {
browser.assert.attributeEquals("body", "data-attr", "some value");
};
this.demoTest = function (browser) {
browser.assert.containsText("#main", "The Night Watch");
};
this.demoTest = function (browser) {
browser.assert.cssClassPresent("#main", "container");
browser.assert.cssClassPresent('#main', ['visible', 'container']);
browser.assert.cssClassPresent('#main', 'visible container');
};
this.demoTest = function (browser) {
browser.assert.cssProperty("#main", "display", "block");
};
this.demoTest = function (browser) {
browser.assert.domPropertyContains('#main', 'classList', 'visible');
// in case the resulting property is an array, several elements could be specified
browser.assert.domPropertyEquals('#main', 'classList', ['class-one', 'class-two']);
browser.assert.domPropertyEquals('#main', 'classList', 'class-one,class-two');
};
this.demoTest = function (browser) {
browser.assert.domPropertyEquals('#main', 'className', 'visible');
// deep equal will be performed
browser.assert.domPropertyEquals('#main', 'classList', ['class-one', 'class-two']);
// split on ',' and deep equal will be performed
browser.assert.domPropertyEquals('#main', 'classList', 'class-one,class-two']);
};
this.demoTest = function (browser) {
browser.assert.elementPresent("#main");
};
this.demoTest = function (browser) {
browser.assert.title("Nightwatch.js");
};
this.demoTest = function (browser) {
browser.assert.urlContains('nightwatchjs.org');
};
this.demoTest = function (browser) {
browser.assert.urlEquals('https://www.google.com');
};
this.demoTest = function (browser) {
browser.assert.value("form.login input[type=text]", "username");
};
this.demoTest = function (browser) {
browser.assert.valueContains("form.login input[type=text]", "username");
};
this.demoTest = function (browser) {
browser.assert.visible('.should_be_visible');
browser.assert.visible({selector: '.should_be_visible'});
browser.assert.visible({selector: '.should_be_visible', supressNotFoundErrors: true});
};
The following are provided as chainable getters to improve the readability of your assertions. They do not provide testing capabilities and the order is not important.
- to
- be
- been
- is
- that
- which
- and
- has
- have
- with
- at
- does
- of
.startWith(value)/.endWith(value)this.demoTest = function (browser) { browser.expect.element('#main').text.to.equal('The Night Watch');
browser.expect.element('#main').text.to.contain('The Night Watch'); browser.expect.element('#main').to.have.css('display').which.equals('block');
};
this.demoTest = function (browser) {
browser.expect.element('#main').text.to.endWith('Watch');
browser.expect.element('#main').text.to.startWith('The');
};
.not
this.demoTest = function (browser) {
browser.expect.element('#main').text.to.not.equal('The Night Watch');
browser.expect.element('#main').text.to.not.contain('The Night Watch');
browser.expect.element('#main').to.have.css('display').which.does.not.equal('block');
};
.before(ms)/.after(ms)
this.demoTest = function (browser) {
browser.expect.element('#main').text.to.contain('The Night Watch').before(1000);
browser.expect.element('#main').text.to.not.contain('The Night Watch').after(500);
};
expect.cookie()
browser.expect.cookie('cookie-name', ['cookie-domain'])
this.demoTest = function (browser) {
browser.expect.cookie('cookie-name').to.contain('cookie-value');
browser.expect.cookie('cookie-name').to.match(/regex/);
browser.expect.cookie('loginCookie', 'example.org').to.contain('cookie-value');
};
expect.element()
browser.element('#selector')
.a(type)Suggest edits
this.demoTest = function (browser) {
browser.expect.element('#q').to.be.an('input');
browser.expect.element('#q').to.be.an('input', 'Testing if #q is an input');
browser.expect.element('#w').to.be.a('span');
}
.active
this.demoTest = function (browser) {
browser.expect.element('#main').to.be.active;
browser.expect.element('#main').to.not.be.active;
browser.expect.element('#main').to.be.active.before(100);
};
.attribute(name)
this.demoTest = function (browser) {
browser.expect.element('body').to.have.attribute('data-attr');
browser.expect.element('body').to.not.have.attribute('data-attr');
browser.expect.element('body').to.not.have.attribute('data-attr', 'Testing if body does not have data-attr');
browser.expect.element('body').to.have.attribute('data-attr').before(100);
browser.expect.element('body').to.have.attribute('data-attr')
.equals('some attribute');
browser.expect.element('body').to.have.attribute('data-attr')
.not.equals('other attribute');
browser.expect.element('body').to.have.attribute('data-attr')
.which.contains('something');
browser.expect.element('body').to.have.attribute('data-attr')
.which.matches(/^something\ else/);
};
.css(property)
this.demoTest = function (browser) {
browser.expect.element('#main').to.have.css('display');
browser.expect.element('#main').to.have.css('display', 'Testing for display');
browser.expect.element('#main').to.not.have.css('display');
browser.expect.element('#main').to.have.css('display').before(100);
browser.expect.element('#main').to.have.css('display').which.equals('block');
browser.expect.element('#main').to.have.css('display').which.contains('some value');
browser.expect.element('#main').to.have.css('display').which.matches(/some\ value/);
};
.enabled
this.demoTest = function (browser) {
browser.expect.element('#weblogin').to.be.enabled;
browser.expect.element('#main').to.not.be.enabled;
browser.expect.element('#main').to.be.enabled.before(100);
};
.present
this.demoTest = function (browser) {
browser.expect.element('#main').to.be.present;
browser.expect.element('#main').to.not.be.present;
browser.expect.element('#main').to.be.present.before(100);
};
.property(name)
this.demoTest = function (browser) {
browser.expect.element('body').to.have.property('className').equals('test-class');
browser.expect.element('body').to.have.property('className').matches(/^something\ else/);
browser.expect.element('body').to.not.have.property('classList').equals('test-class');
browser.expect.element('body').to.have.property('classList').deep.equal(['class-one', 'class-two']);
browser.expect.element('body').to.have.property('classList').contain('class-two');
};
.selected
this.demoTest = function (browser) {
browser.expect.element('#main').to.be.selected;
browser.expect.element('#main').to.not.be.selected;
browser.expect.element('#main').to.be.selected.before(100);
};
.text
this.demoTest = function (browser) {
browser.expect.element('#main').text.to.equal('The Night Watch');
browser.expect.element('#main').text.to.not.equal('The Night Watch');
browser.expect.element('#main').text.to.equal('The Night Watch').before(100);
browser.expect.element('#main').text.to.contain('The Night Watch');
browser.expect.element('#main').text.to.match(/The\ Night\ Watch/);
};
.value
this.demoTest = function (browser) {
browser.expect.element('#q').to.have.value.that.equals('search');
browser.expect.element('#q').to.have.value.not.equals('search');
browser.expect.element('#q').to.have.value.which.contains('search');
browser.expect.element('#q').to.have.value.which.matches(/search/);
};
.visible
this.demoTest = function (browser) {
browser.expect.element('#main').to.be.visible;
browser.expect.element('#main').to.not.be.visible;
browser.expect.element('#main').to.be.visible.before(100);
};
expect.elements()
browser.elements('#selector')
.elements().count
this.demoTest = function (browser) {
browser.expect.elements('div').count.to.equal(10);
browser.expect.elements('p').count.to.not.equal(1);
}
.expect.title()
this.demoTest = function (browser) {
browser.expect.title().to.contain('value');
browser.expect.title().to.match(/value/);
};
.expect.url()
this.demoTest = function (browser) {
browser.expect.url().to.contain('https://');
browser.expect.url().to.endWith('.org');
};