Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions nightwatch/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Nightwatch test project for Testomat.io

### Install dependencies

`npm install`

### Run tests

`TESTOMATIO={apiKey} npx nightwatch --reporter @testomatio/reporter/nightwatch`
git
86 changes: 86 additions & 0 deletions nightwatch/nightwatch.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
// Refer to the online docs for more details:
// https://nightwatchjs.org/gettingstarted/configuration/
//

// _ _ _ _ _ _ _
// | \ | |(_) | | | | | | | |
// | \| | _ __ _ | |__ | |_ __ __ __ _ | |_ ___ | |__
// | . ` || | / _` || '_ \ | __|\ \ /\ / / / _` || __| / __|| '_ \
// | |\ || || (_| || | | || |_ \ V V / | (_| || |_ | (__ | | | |
// \_| \_/|_| \__, ||_| |_| \__| \_/\_/ \__,_| \__| \___||_| |_|
// __/ |
// |___/

module.exports = {
// An array of folders (excluding subfolders) where your tests are located;
// if this is not specified, the test source must be passed as the second argument to the test runner.
src_folders: ['test','nightwatch'],
// See https://nightwatchjs.org/guide/concepts/page-object-model.html
page_objects_path: [],

// See https://nightwatchjs.org/guide/extending-nightwatch/adding-custom-commands.html
custom_commands_path: [],

// See https://nightwatchjs.org/guide/extending-nightwatch/adding-custom-assertions.html
custom_assertions_path: [],

// See https://nightwatchjs.org/guide/extending-nightwatch/adding-plugins.html
plugins: [],

// See https://nightwatchjs.org/guide/concepts/test-globals.html
globals_path: '',

webdriver: {},

test_workers: {
enabled: true
},

test_settings: {
default: {
disable_error_log: false,
launch_url: 'http://localhost',

screenshots: {
enabled: false,
path: 'screens',
on_failure: true
},

desiredCapabilities: {
browserName: 'chrome'
},

webdriver: {
start_process: true,
server_path: ''
},

},

chrome: {
desiredCapabilities: {
browserName: 'chrome',
'goog:chromeOptions': {
// More info on Chromedriver: https://sites.google.com/a/chromium.org/chromedriver/
args: [
//'--no-sandbox',
//'--ignore-certificate-errors',
//'--allow-insecure-localhost',
//'--headless=new'
]
}
},

webdriver: {
start_process: true,
server_path: '',
cli_args: [
// --verbose
]
}
},

},

};
30 changes: 30 additions & 0 deletions nightwatch/nightwatch/duckDuckGo.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import {ExtendDescribeThis} from 'nightwatch';

interface CustomThis {
duckDuckGoUrl: string;
searchBox: string;
submitButton: string;
}

// callback passed to `describe` should be a regular function (not an arrow function).
describe('duckduckgo example', function(this: ExtendDescribeThis<CustomThis>) {
this.duckDuckGoUrl = 'https://duckduckgo.com';
this.searchBox = 'input[name=q]';
this.submitButton = '*[type=submit]';

// callback can be a regular function as well as an arrow function.
beforeEach(function(this: ExtendDescribeThis<CustomThis>, browser) {
browser.navigateTo(this.duckDuckGoUrl!);
});

// no need to specify `this` parameter when passing an arrow function
// as callback to `it`.
it('Search Nightwatch.js and check results', (browser) => {
browser
.waitForElementVisible(this.searchBox!)
.sendKeys(this.searchBox!, ['Nightwatch.js'])
.click(this.submitButton!)
.assert.visible('#react-layout')
.assert.textContains('#react-layout', 'Nightwatch.js');
});
});
18 changes: 18 additions & 0 deletions nightwatch/nightwatch/ecosia.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
describe('Ecosia.org Demo', function() {
this.tags = ['demo'];

before(browser => browser.navigateTo('https://www.ecosia.org/'));

it('Demo test ecosia.org', function(browser) {
browser
.waitForElementVisible('body')
.assert.titleContains('Ecosia')
.assert.visible('input[type=search]')
.setValue('input[type=search]', 'nightwatch')
.assert.visible('button[type=submit]')
.click('button[type=submit]')
.assert.textContains('.layout__content', 'Nightwatch.js');
});

after(browser => browser.end());
});
46 changes: 46 additions & 0 deletions nightwatch/nightwatch/github.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import {NightwatchAPI, NightwatchTests} from 'nightwatch';

const home: NightwatchTests = {
'Github Title test': () => {
browser
.url('https://github.com')
.assert.titleContains('GitHub');
},

'Github search for nightwatch repository': () => {
browser
.url('https://github.com/search')
.clearValue('[placeholder=\'Search GitHub\']')
.setValue('[placeholder=\'Search GitHub\']', 'nightwatch')
.perform(function(this: NightwatchAPI) {
const actions = this.actions({async: true});

return actions.keyDown(this.Keys['ENTER']).keyUp(this.Keys['ENTER']);
})
.waitForElementVisible('.header-search-button')
.assert.textEquals('.header-search-button', 'nightwatch')
.waitForElementVisible('div[data-testid="results-list"]:first-child')
.assert.textContains(
'div[data-testid="results-list"]:first-child',
'Integrated end-to-end testing framework written in Node.js and using W3C Webdriver API'
);
},

'Github login with fake credentials': () => {
browser
.url('https://github.com/login')
.clearValue('#login_field')
.setValue('#login_field', 'nightwatch')
.clearValue('#password')
.setValue('#password', 'testpassword')
.waitForElementVisible('[value=\'Sign in\']')
.click('[value=\'Sign in\']')
.assert.textContains(
'#js-flash-container .flash.flash-error',
'Incorrect username or password.'
)
.end();
}
};

export default home;
21 changes: 21 additions & 0 deletions nightwatch/nightwatch/google.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { NightwatchAPI, NightwatchTests } from 'nightwatch';

const home: NightwatchTests = {
'Google title test': () => {
browser.url('https://google.com/ncr').assert.titleEquals('Google');
},

'Google search test': () => {
browser
.setValue('textarea[name=q]', 'nightwatchjs')
.perform(function (this: NightwatchAPI) {
const actions = this.actions({ async: true });

return actions.keyDown(this.Keys['ENTER']).keyUp(this.Keys['ENTER']);
})
.waitForElementVisible('#main')
.assert.textContains('#main', 'Nightwatch.js');
}
};

export default home;
18 changes: 18 additions & 0 deletions nightwatch/nightwatch/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"compilerOptions": {
"target": "esnext",
"module": "commonjs",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"moduleResolution": "node",
"resolveJsonModule": true,
"skipLibCheck": true,
"allowJs": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true
},
"ts-node": {
"transpileOnly": true
},
"include": ["."]
}
38 changes: 38 additions & 0 deletions nightwatch/nightwatch/unit-filename1.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { assert } from "nightwatch";


it('test inside a file', function () {
assert.ok(true);
});

describe('suite name for positive tests', function () {
this.tags = ['demo'];

it('test inside a suite', function () {
assert.ok(true);
});

describe('nested suite name', function () {
it('test inside nested suite', function () {
assert.ok(true);
});
});

});


describe('suite name for negative tests', function () {

it.skip('skipped test', function () {
assert.ok(true);
});

it('failed test', function () {
assert.ok(false);
});

it('test throwing an error', function () {
throw new Error('Test error');
});
});

18 changes: 18 additions & 0 deletions nightwatch/nightwatch/unit-filename2.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { assert } from "nightwatch";

describe('suite name for positive tests 2', function () {
this.tags = ['demo'];

it('test inside a suite 2', function () {
assert.ok(true);
console.log('its fine');
});
});

describe('suite name for positive tests 2', function () {
this.tags = ['demo'];

it('test inside a suite 2', function () {
assert.ok(true);
});
});
22 changes: 22 additions & 0 deletions nightwatch/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "nightwatch",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"type": "commonjs",
"description": "",
"devDependencies": {
"@swc/core": "^1.11.8",
"nightwatch": "^3.12.0",
"ts-node": "^10.9.2",
"typescript": "^5.8.2"
},
"dependencies": {
"@testomatio/reporter": "^2.1.0-beta-nightwatch"
}
}
18 changes: 18 additions & 0 deletions nightwatch/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"compilerOptions": {
"target": "esnext",
"module": "commonjs",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"moduleResolution": "node",
"resolveJsonModule": true,
"skipLibCheck": true,
"allowJs": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true
},
"ts-node": {
"transpileOnly": true
},
"include": ["."]
}