Skip to content

Commit

Permalink
fix: Tests after webpack 5 migration
Browse files Browse the repository at this point in the history
Adjusting tests to new webpack and update test dependencies
  • Loading branch information
TheGreatRefrigerator committed Dec 7, 2022
1 parent 47185f8 commit 9865f2c
Show file tree
Hide file tree
Showing 39 changed files with 2,307 additions and 1,866 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
/dist/
/*.js
/test/unit/coverage/
/test/integration/mockups
/src/ors-js/node_modules/
11 changes: 11 additions & 0 deletions docs/learned-lessons.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,14 @@ require('@babel/register')
## Use babel.config.js to support dynamic compiling rules

`babel.config.js` replaces `.babelrc` and can have dynamic behavior

## Testing for colors

Chromedriver and geckodriver differ in the way they return rgb style colors.
While chromedriver gives back `rgba`, geckodriver returns `rgb` which is both valid due to a lax requirement definition
for browsers.
When checking for specific colors, currently a regex should be used to match both returned values, e.g.

/rgba?\(255, 0, 0(, 1)?\)/

to match both `rgb(255, 0, 0)` and `rgba(255, 0, 0, 1)`.
215 changes: 215 additions & 0 deletions nightwatch.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
// Autogenerated by Nightwatch
// Refer to the online docs for more details: https://nightwatchjs.org/gettingstarted/configuration/
const config = require("./config")
const Services = {}; loadServices();

module.exports = {
// An array of folders (excluding sub-folders) 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: ['tests/e2e/specs/directions.spec.js'],
output_folder: 'tests/e2e/reports',

// See https://nightwatchjs.org/guide/working-with-page-objects/
page_objects_path: '',

// See https://nightwatchjs.org/guide/extending-nightwatch/#writing-custom-commands
custom_commands_path: 'tests/e2e/commands',

// See https://nightwatchjs.org/guide/extending-nightwatch/#writing-custom-assertions
custom_assertions_path: 'tests/e2e/custom-assertions',

// See https://nightwatchjs.org/guide/#external-globals
globals_path : '',

webdriver: {},

test_settings: {
default: {
disable_error_log: false,
baseUrl: 'http://localhost:' + (process.env.PORT || config.dev.port),

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

desiredCapabilities : {
browserName : 'chrome',
'goog:chromeOptions' : {
args: [
'--no-sandbox',
'--ignore-certificate-errors',
'--allow-insecure-localhost',
'--headless',
'--disable-gpu',
],
prefs:{
download:{
prompt_for_download: false,
default_directory:require('path').resolve(__dirname + 'tests/e2e/downloads')
}
}
}
},

webdriver: {
start_process: true,
server_path: (Services.chromedriver ? Services.chromedriver.path : '')
}
},

// safari: {
// desiredCapabilities : {
// browserName : 'safari',
// alwaysMatch: {
// acceptInsecureCerts: false
// }
// },
// webdriver: {
// port: 4445,
// start_process: true,
// server_path: '/usr/bin/safaridriver'
// }
// },

firefox: {
desiredCapabilities : {
browserName : 'firefox',
alwaysMatch: {
acceptInsecureCerts: true,
'moz:firefoxOptions': {
"args": [
'-headless',
'-verbose'
],
prefs:{
download:{
prompt_for_download: false,
default_directory:require('path').resolve(__dirname + 'tests/e2e/downloads')
}
}
}
}

},
webdriver: {
start_process: true,
port: 4444,
server_path: (Services.geckodriver ? Services.geckodriver.path : ''),
cli_args: [
// very verbose geckodriver logs
// '-vv'
]
}
},

chrome: {
desiredCapabilities : {
browserName : 'chrome',
'goog:chromeOptions' : {
// More info on Chromedriver: https://sites.google.com/a/chromium.org/chromedriver/
//
// This tells Chromedriver to run using the legacy JSONWire protocol (not required in Chrome 78)
w3c: false,
args: [
'--no-sandbox',
'--ignore-certificate-errors',
'--allow-insecure-localhost',
'--headless',
// '--disable-gpu',
],
prefs:{
download:{
prompt_for_download: false,
default_directory:require('path').resolve(__dirname + 'tests/e2e/downloads')
}
}
}
},

webdriver: {
start_process: true,
port: 4445,
server_path: (Services.chromedriver ? Services.chromedriver.path : ''),
cli_args: [
// --verbose
]
}
},

edge: {
desiredCapabilities : {
browserName : 'MicrosoftEdge',
'ms:edgeOptions' : {
w3c: false,
// More info on EdgeDriver: https://docs.microsoft.com/en-us/microsoft-edge/webdriver-chromium/capabilities-edge-options
args: [
//'--headless'
]
}
},

webdriver: {
start_process: true,
// Download msedgedriver from https://docs.microsoft.com/en-us/microsoft-edge/webdriver-chromium/
// and set the location below:
server_path: '',
cli_args: [
// --verbose
]
}
},
//
// //////////////////////////////////////////////////////////////////////////////////
// // Configuration for when using the Selenium service, either locally or remote, |
// // like Selenium Grid |
// //////////////////////////////////////////////////////////////////////////////////
// selenium_server: {
// // Selenium Server is running locally and is managed by Nightwatch
// selenium: {
// start_process: true,
// port: 4444,
// server_path: (Services.seleniumServer ? Services.seleniumServer.path : ''),
// cli_args: {
// 'webdriver.gecko.driver': (Services.geckodriver ? Services.geckodriver.path : ''),
// 'webdriver.chrome.driver': (Services.chromedriver ? Services.chromedriver.path : '')
// }
// }
// },
//
// 'selenium.chrome': {
// extends: 'selenium_server',
// desiredCapabilities: {
// browserName: 'chrome',
// chromeOptions : {
// w3c: false
// }
// }
// },
//
// 'selenium.firefox': {
// extends: 'selenium_server',
// desiredCapabilities: {
// browserName: 'firefox',
// 'moz:firefoxOptions': {
// args: [
// // '-headless',
// // '-verbose'
// ]
// }
// }
// }
}
};

function loadServices() {

try {
Services.chromedriver = require('chromedriver');
} catch (err) {}

try {
Services.geckodriver = require('geckodriver');
} catch (err) {}
}

0 comments on commit 9865f2c

Please sign in to comment.