Skip to content

Commit

Permalink
fix: change some default values to more commonly used
Browse files Browse the repository at this point in the history
BREAKING CHANGE:
- change default value for "saveHistory" option from "false" to "true"
- change default value for "antialiasingTolerance" option from "0" to "4"
- change default value for "compositeImage" option from "false" to "true"
- change default value for "takeScreenshotOnFails.assertViewFail" option from "false" to "true"
- change default value for "takeScreenshotOnFailsMode" option from "viewport" to "fullpage"
- change default value for "httpTimeout" option from "90000" to "30000"
- change default value for "pageLoadTimeout" option from "300000" to " 20000"
- change default value for "sessionQuitTimeout" option from "90000" to "5000"
- change default value for "takeScreenshotOnFailsTimeout" option from "90000" to "5000"
  • Loading branch information
DudaGod committed Jun 11, 2022
1 parent ca35198 commit 40b8343
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 39 deletions.
36 changes: 18 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ Parameters:
- ignoreElements (optional) `String|String[]` – elements, matching specified selectors will be ignored when comparing images
- tolerance (optional) `Number` – overrides config [browsers](#browsers).[tolerance](#tolerance) value
- antialiasingTolerance (optional) `Number` – overrides config [browsers](#browsers).[antialiasingTolerance](#antialiasingTolerance) value
- allowViewportOverflow (optional) `Boolean` – by default Hermione throws an error if element is outside the viewport bounds. This option disables check that element is outside of the viewport left, top, right or bottom bounds. In this case only visible part of the element will be captured. But if set browser option [compositeImage](#compositeimage) with `true` value, then in the resulting screenshot will appear the whole element with not visible parts outside of the viewport.
- allowViewportOverflow (optional) `Boolean` – by default Hermione throws an error if element is outside the viewport bounds. This option disables check that element is outside of the viewport left, top, right or bottom bounds. And in this case if browser option [compositeImage](#compositeimage) set to `false`, then only visible part of the element will be captured. But if [compositeImage](#compositeimage) set to `true` (default), then in the resulting screenshot will appear the whole element with not visible parts outside of the bottom bounds of viewport.
- captureElementFromTop (optional) `Boolean` - ability to set capture element from the top area or from current position. In the first case viewport will be scrolled to the top of the element. Default value is `true`
- compositeImage (optional) `Boolean` - overrides config [browsers](#browsers).[compositeImage](#compositeImage) value
- screenshotDelay (optional) `Number` - overrides config [browsers](#browsers).[screenshotDelay](#screenshotDelay) value
Expand Down Expand Up @@ -721,16 +721,16 @@ Option name | Description
`sessionEnvFlags` | Environment flags that determine which protocol will be used in created browser session. Default value is `{}`.
`waitTimeout` | Timeout for web page event. Default value is `1000` ms.
`waitInterval` | Interval for web page event. Default value is `250` ms.
`httpTimeout` | Timeout for any requests to Selenium server. Default value is `90000` ms.
`httpTimeout` | Timeout for any requests to Selenium server. Default value is `30000` ms.
`urlHttpTimeout` | Timeout for `/url` request to Selenium server. Default value is `httpTimeout`.
`pageLoadTimeout` | Timeout for the page loading to complete. Default value is `300000` ms.
`pageLoadTimeout` | Timeout for the page loading to complete. Default value is `20000` ms.
`sessionRequestTimeout` | Timeout for getting a browser session. Default value is `httpTimeout`.
`sessionQuitTimeout` | Timeout for quitting a session. Default value is `httpTimeout`.
`sessionQuitTimeout` | Timeout for quitting a session. Default value is `5000`.
`testTimeout` | Timeout for test execution (in milliseconds). Default value is `null`, in this case will be used common timeout for all browsers from `system.mochaOpts.timeout`.
`sessionsPerBrowser` | Number of sessions which are run simultaneously. Default value is `1`.
`takeScreenshotOnFails` | Options for setting up taking a screenshot of a test fail. Default value is `{testFail: true, assertViewFail: false}`.
`takeScreenshotOnFailsMode` | Mode for taking a screenshot on test fail. Available options are `fullpage` and `viewport`. Default value is `viewport`.
`takeScreenshotOnFailsTimeout`| Timeout for taking screenshot on test fail. Default value is `httpTimeout`.
`takeScreenshotOnFailsMode` | Mode for taking a screenshot on test fail. Available options are `fullpage` and `viewport`. Default value is `fullpage`.
`takeScreenshotOnFailsTimeout`| Timeout for taking screenshot on test fail. Default value is `5000`.
`testsPerSession` | Maximum amount of tests (`it`s) to run in each web driver session.
`retry` | How many times a test should be rerun. Default value is `0`.
`shouldRetry` | Function that determines whether to make a retry. By default returns `true `if retry attempts are available otherwise returns `false`.
Expand All @@ -742,15 +742,15 @@ Option name | Description
`waitOrientationChange` | Allows to wait until screen orientation is changed. Default value is `true`.
`resetCursor` | Allows to configure whether to move mouse cursor to `body` coordinates `(0, 0)` before each test run.
`tolerance` | Maximum allowed [CIEDE2000](http://en.wikipedia.org/wiki/Color_difference#CIEDE2000) difference between colors. Default value is `2.3`.
`antialiasingTolerance` | Minimum difference in brightness between the darkest/lightest pixel (which is adjacent to the antiasing pixel) and theirs adjacent pixels. Default value is `0`.
`antialiasingTolerance` | Minimum difference in brightness between the darkest/lightest pixel (which is adjacent to the antiasing pixel) and theirs adjacent pixels. Default value is `4`.
`compareOpts` | Options for comparing images.
`buildDiffOpts` | Options for building diff image.
`assertViewOpts` | Options for `assertView` command, used by default.
`screenshotsDir` | Directory to save reference images for command `assertView`. Default dir is `hermione/screens` which is relative to `process.cwd()`.
`strictTestsOrder` | `hermione` will guarantee tests order in [readTests](#readtests) results. `false` by default.
`compositeImage` | Allows testing of regions which bottom bounds are outside of a viewport height (default: false). In the resulting screenshot the area which fits the viewport bounds will be joined with the area which is outside of the viewport height.
`compositeImage` | Allows testing of regions which bottom bounds are outside of a viewport height. In the resulting screenshot the area which fits the viewport bounds will be joined with the area which is outside of the viewport height. `true` by default.
`screenshotMode` | Image capture mode.
`saveHistory` | Allows to save history of all executed commands. `false` by default.
`saveHistory` | Allows to save history of all executed commands. `true` by default.
`agent` | Allows to use a custom `http`/`https`/`http2` [agent](https://www.npmjs.com/package/got#agent) to make requests. Default value is `null`.
`headers` | Allows to set custom [headers](https://github.com/sindresorhus/got/blob/main/documentation/2-options.md#headers) to pass into every webdriver request. These headers aren't passed into browser request. Read more about this option in [wdio](https://github.com/sindresorhus/got/blob/main/documentation/2-options.md#headers). Default value is `null`.
`transformRequest` | Allows to intercept [HTTP request options](https://github.com/sindresorhus/got#options) before a WebDriver request is made. Default value is `null`.
Expand Down Expand Up @@ -805,20 +805,20 @@ For example:
```

#### httpTimeout
Timeout for any requests to Selenium server. Default value is `90000` ms.
Timeout for any requests to Selenium server. Default value is `30000` ms.

#### urlHttpTimeout
Timeout for `/url` request to Selenium server. Default value is `httpTimeout`.
It may be useful when opening url takes a long time (for example a lot of logic is executed in middlewares), and you don't want to increase timeout for other commands.

#### pageLoadTimeout
Timeout for the page loading to complete. Default value is `300000` ms.
Timeout for the page loading to complete. Default value is `20000` ms.

#### sessionRequestTimeout
Timeout for getting a browser session. Default value is `httpTimeout`.

#### sessionQuitTimeout
Timeout for quitting a session. Default value is `httpTimeout`.
Timeout for quitting a session. Default value is `5000`.

#### testTimeout
Timeout for test execution (in milliseconds).
Expand All @@ -838,16 +838,16 @@ Number of sessions which are run simultaneously. Global value for all browsers.
Options for setting up taking a screenshot of a test fail. Can be an object with `testFail` and `assertViewFail` keys.

* `testFail` (default: `true`) – takes a screenshot when an error occurs in the test, except `assertView` fail.
* `assertViewFail` (default: `false`) – takes a screenshot if the test fails on the `assetView` command.
* `assertViewFail` (default: `true`) – takes a screenshot if the test fails on the `assetView` command.

#### takeScreenshotOnFailsMode
Mode for taking a screenshot on test fail. There are two available options:

* `fullpage` – Hermione will take a screenshot of the entire page from top.
* `viewport`Default value. Hermione will take a screenshot of the current viewport.
* `fullpage` – Hermione will take a screenshot of the entire page from top. Default value.
* `viewport` – Hermione will take a screenshot of the current viewport.

#### takeScreenshotOnFailsTimeout
Timeout for taking screenshot on test fail. Default value is `httpTimeout`.
Timeout for taking screenshot on test fail. Default value is `5000`.

#### testsPerSession
Maximum amount of tests (`it`s) to run in each web driver session. After limit is reached, session will be closed and new one will be started.
Expand Down Expand Up @@ -947,7 +947,7 @@ Directory to save reference images for command `assertView`. Default dir is `her

#### compositeImage

Allows testing of regions which bottom bounds are outside of a viewport height (default: false). In the resulting screenshot the area which fits the viewport bounds will be joined with the area which is outside of the viewport height.
Allows testing of regions which bottom bounds are outside of a viewport height (default: true). In the resulting screenshot the area which fits the viewport bounds will be joined with the area which is outside of the viewport height.

#### screenshotMode

Expand All @@ -961,7 +961,7 @@ By default, `screenshotMode` on android browsers is set to `viewport` to work ar

#### saveHistory

Allows to save history of all executed commands. `false` by default.
Allows to save history of all executed commands. `true` by default.

Some plugins can rely on this history, for instance:
- [hermione-profiler](https://github.com/gemini-testing/hermione-profiler)
Expand Down
18 changes: 9 additions & 9 deletions lib/config/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = {
screenshotsDir: 'hermione/screens',
diffColor: '#ff00ff',
tolerance: 2.3,
antialiasingTolerance: 0,
antialiasingTolerance: 4,
compareOpts: {
shouldCluster: false,
clustersSize: 10,
Expand All @@ -28,23 +28,23 @@ module.exports = {
calibrate: false,
screenshotMode: 'auto',
screenshotDelay: 0,
compositeImage: false,
compositeImage: true,
prepareBrowser: null,
prepareEnvironment: null,
waitTimeout: 1000,
waitInterval: 250,
httpTimeout: 90000,
httpTimeout: 30000,
urlHttpTimeout: null,
pageLoadTimeout: null,
pageLoadTimeout: 20000,
sessionRequestTimeout: null,
sessionQuitTimeout: null,
sessionQuitTimeout: 5000,
testTimeout: null,
takeScreenshotOnFails: {
testFail: true,
assertViewFail: false
assertViewFail: true
},
takeScreenshotOnFailsTimeout: null,
takeScreenshotOnFailsMode: 'viewport',
takeScreenshotOnFailsTimeout: 5000,
takeScreenshotOnFailsMode: 'fullpage',
reporters: ['flat'],
debug: false,
parallelLimit: Infinity,
Expand All @@ -66,7 +66,7 @@ module.exports = {
waitOrientationChange: true,
resetCursor: true,
strictTestsOrder: false,
saveHistory: false,
saveHistory: true,
fileExtensions: ['.js'],
outputDir: null,
agent: null,
Expand Down
2 changes: 1 addition & 1 deletion test/lib/browser/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function createBrowserConfig_(opts = {}) {
key: null,
region: null,
headless: null,
saveHistory: false
saveHistory: true
});

return {
Expand Down
8 changes: 4 additions & 4 deletions test/lib/config/browser-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -1149,7 +1149,7 @@ describe('config browser-options', () => {

assert.deepEqual(config.takeScreenshotOnFails, {
testFail: true,
assertViewFail: false
assertViewFail: true
});
});

Expand All @@ -1161,7 +1161,7 @@ describe('config browser-options', () => {
browsers: {
b1: mkBrowser_(),
b2: mkBrowser_({takeScreenshotOnFails: {
assertViewFail: true
assertViewFail: false
}})
}
};
Expand All @@ -1172,11 +1172,11 @@ describe('config browser-options', () => {

assert.deepEqual(config.browsers.b1.takeScreenshotOnFails, {
testFail: false,
assertViewFail: false
assertViewFail: true
});
assert.deepEqual(config.browsers.b2.takeScreenshotOnFails, {
testFail: false,
assertViewFail: true
assertViewFail: false
});
});
});
Expand Down
14 changes: 7 additions & 7 deletions typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -447,10 +447,10 @@ declare namespace Hermione {
* Disables check that element is outside of the viewport left, top, right or bottom bounds.
*
* @remarks
* By default Hermione throws an error if element is outside the viewport bounds. This option disables this behaviour.
* If option set to `true` then only visible part of the element will be captured.
* But if set browser option {@link https://github.com/gemini-testing/hermione#compositeimage compositeImage} with `true` value,
* then in the resulting screenshot will appear the whole element with not visible parts outside of the viewport bottom bound.
* By default Hermione throws an error if element is outside the viewport bounds.
* This option disables check that element is outside of the viewport left, top, right or bottom bounds.
* And in this case if browser option {@link https://github.com/gemini-testing/hermione#compositeimage compositeImage} set to `false`, then only visible part of the element will be captured.
* But if {@link https://github.com/gemini-testing/hermione#compositeimage compositeImage} set to `true` (default), then in the resulting screenshot will appear the whole element with not visible parts outside of the bottom bounds of viewport.
*
* @defaultValue `false`
*/
Expand All @@ -477,7 +477,7 @@ declare namespace Hermione {
* @remarks
* Read more about this option in {@link https://github.com/gemini-testing/looks-same#comparing-images-with-ignoring-antialiasing looks-same}
*
* @defaultValue `0`
* @defaultValue `4`
*/
antialiasingTolerance?: number;
/**
Expand All @@ -487,7 +487,7 @@ declare namespace Hermione {
* @remarks
* In the resulting screenshot the area which fits the viewport bounds will be joined with the area which is outside of the viewport height.
*
* @defaultValue `false`
* @defaultValue `true`
*/
compositeImage?: boolean;
/**
Expand All @@ -506,7 +506,7 @@ declare namespace Hermione {
* @remarks
* Useful when you capture the modal (popup). In this case a duplicate of the modal appears on the screenshot.
* That happens because we scroll the page using `window` selector, which scroll only the background of the modal, and the modal itself remains in place.
* Default value is `undefined` (it means scroll relative to `window`). Works only when `compositeImage` is `true`.
* Default value is `undefined` (it means scroll relative to `window`). Works only when `compositeImage` is `true` (default).
*
* @defaultValue `undefined`
*/
Expand Down

0 comments on commit 40b8343

Please sign in to comment.