Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DuckDuckGo ja kodutöö Anna Andreas KTA-18E #80

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
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
19 changes: 19 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
env:
commonjs: true
es6: true
node: true
extends: airbnb-base
globals:
Atomics: readonly
SharedArrayBuffer: readonly
parserOptions:
ecmaVersion: 2018
rules:
no-console: off
func-names: off
import/no-extraneous-dependencies: off
global-require: off
no-template-curly-in-string: off
no-plusplus: off
# to avoid windows vs unix conflicts
linebreak-style: off
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ nightwatch/chromedriver
reports
screenshots
.env

*.log
6 changes: 6 additions & 0 deletions .vs/VSWorkspaceState.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"ExpandedNodes": [
""
],
"PreviewInSolutionExplorer": false
}
Binary file added .vs/learn-nightwatch/v15/.suo
Binary file not shown.
Binary file added .vs/slnx.sqlite
Binary file not shown.
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,9 @@ _**Try it**_ on your local machine in 5 mins by following these _**3 easy steps*
Clone the repository by _copy-pasting_ the following command into your terminal:

```sh
git clone https://github.com/dwyl/learn-nightwatch.git && cd learn-nightwatch && cp sample.env .env
git clone https://github.com/eritikass/learn-nightwatch.git && cd learn-nightwatch
```

> Note: if you're _curious_ what that last part is, see: https://github.com/dwyl/env2

### 2. Install<sup>1</sup>

Install the *required* dependencies
Expand All @@ -86,13 +84,23 @@ including Selenium Server and `chromedriver`:
npm install
```

> NB: you need to have [nodejs](https://nodejs.org/en/download/) and [java](https://www.java.com/en/download/) installed locally...

### 3. Run (_tests_)<sup>2</sup>

Run the Nightwatch tests:

```sh
npm test

# or run specific test with
npm test -- test/e2e/github.js


# this project also has eslint setup, run linter
npm run lint
# autfix with eslint
npm run lint -- --fix
```


Expand Down
81 changes: 41 additions & 40 deletions nightwatch.conf.BASIC.js
Original file line number Diff line number Diff line change
@@ -1,65 +1,66 @@
require('env2')('.env'); // optionally store youre Evironment Variables in .env
const seleniumServer = require("selenium-server");
const chromedriver = require("chromedriver");
const SCREENSHOT_PATH = "./screenshots/";
const seleniumServer = require('selenium-server');
const chromedriver = require('chromedriver');

const SCREENSHOT_PATH = './screenshots/';

// we use a nightwatch.conf.js file so we can include comments and helper functions
module.exports = {
"src_folders": [
"test/e2e"// Where you are storing your Nightwatch e2e tests
src_folders: [
'test/e2e', // Where you are storing your Nightwatch e2e tests
],
"output_folder": "./reports", // reports (test outcome) output by nightwatch
"selenium": {
"start_process": true, // tells nightwatch to start/stop the selenium process
"server_path": seleniumServer.path,
"host": "127.0.0.1",
"port": 4444, // standard selenium port
"cli_args": {
"webdriver.chrome.driver" : chromedriver.path
}
output_folder: './reports', // reports (test outcome) output by nightwatch
selenium: {
start_process: true, // tells nightwatch to start/stop the selenium process
server_path: seleniumServer.path,
host: '127.0.0.1',
port: 4444, // standard selenium port
cli_args: {
'webdriver.chrome.driver': chromedriver.path,
},
},
"test_settings": {
"default": {
"screenshots": {
"enabled": true, // if you want to keep screenshots
"path": './screenshots' // save screenshots here
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.
globals: {
waitForConditionTimeout: 5000, // sometimes internet is slow so wait.
},
desiredCapabilities: { // use Chrome as the default browser for tests
browserName: 'chrome',
},
"desiredCapabilities": { // use Chrome as the default browser for tests
"browserName": "chrome"
}
},
"chrome": {
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true // turn off to test progressive enhancement
}
}
}
}
chrome: {
desiredCapabilities: {
browserName: 'chrome',
javascriptEnabled: true, // turn off to test progressive enhancement
},
},
},
};

function padLeft (count) { // theregister.co.uk/2016/03/23/npm_left_pad_chaos/
return count < 10 ? '0' + count : count.toString();
function padLeft(count) { // theregister.co.uk/2016/03/23/npm_left_pad_chaos/
return count < 10 ? `0${count}` : count.toString();
}

var FILECOUNT = 0; // "global" screenshot file count
let FILECOUNT = 0; // "global" screenshot file count
/**
* The default is to save screenshots to the root of your project even though
* there is a screenshots path in the config object above! ... so we need a
* function that returns the correct path for storing our screenshots.
* While we're at it, we are adding some meta-data to the filename, specifically
* the Platform/Browser where the test was run and the test (file) name.
*/
function imgpath (browser) {
var a = browser.options.desiredCapabilities;
var meta = [a.platform];
function imgpath(browser) {
const a = browser.options.desiredCapabilities;
const meta = [a.platform];
meta.push(a.browserName ? a.browserName : 'any');
meta.push(a.version ? a.version : 'any');
meta.push(a.name); // this is the test filename so always exists.
var metadata = meta.join('~').toLowerCase().replace(/ /g, '');
return SCREENSHOT_PATH + metadata + '_' + padLeft(FILECOUNT++) + '_';
const metadata = meta.join('~').toLowerCase().replace(/ /g, '');
return `${SCREENSHOT_PATH + metadata}_${padLeft(FILECOUNT++)}_`;
}

module.exports.imgpath = imgpath;
Expand Down
Loading