From ed50fcc05fdd24543d08ea75968ccc184b0a1aa9 Mon Sep 17 00:00:00 2001 From: shadowusr Date: Tue, 6 Aug 2024 01:56:03 +0300 Subject: [PATCH] lint: fix formatting --- .../component-testing.mdx | 15 ++-- .../current/commands/mock/respond.mdx | 82 +++++++++++-------- .../current/commands/mock/respondOnce.mdx | 3 +- .../current/commands/overview.mdx | 6 +- .../current/guides/how-to-debug-test.mdx | 4 +- .../current/guides/how-to-get-report.mdx | 38 ++++++--- .../current/guides/how-to-hide-scrollbars.mdx | 4 +- .../current/guides/how-to-use-cdp.mdx | 6 +- .../how-to-upgrade-hermione-to-4.mdx | 18 ++-- .../how-to-upgrade-hermione-to-5.mdx | 1 + .../how-to-upgrade-hermione-to-6.mdx | 4 +- .../how-to-upgrade-hermione-to-7.mdx | 1 + .../how-to-upgrade-hermione-to-8.mdx | 37 +++++---- .../current/reference/testplane-events.mdx | 41 ++++++---- 14 files changed, 157 insertions(+), 103 deletions(-) diff --git a/i18n/en/docusaurus-plugin-content-blog/component-testing.mdx b/i18n/en/docusaurus-plugin-content-blog/component-testing.mdx index 781a17f..7bc02cd 100644 --- a/i18n/en/docusaurus-plugin-content-blog/component-testing.mdx +++ b/i18n/en/docusaurus-plugin-content-blog/component-testing.mdx @@ -151,8 +151,9 @@ it("should render react button", async ({ browser }) => { You can find fully working examples [here](https://github.com/gemini-testing/testplane/tree/master/examples/component-testing). - - only components written in React in `.jsx` and `.tsx` files are supported. Vue support - is also planned; - no access to `currentTest` from hooks and tests; - the @testplane/global-hook plugin is temporarily not supported. + - only components written in React in `.jsx` and `.tsx` files are supported. Vue support is also + planned; - no access to `currentTest` from hooks and tests; - the @testplane/global-hook plugin + is temporarily not supported. ### What additional features are supported? @@ -175,10 +176,10 @@ Calling the `log`, `info`, `warn`, `error`, `debug`, and `table` commands on the This functionality provides our users with new capabilities: -- isolated testing of React components in a real browser; -- stability and reproducibility of test results compared to JSDom; -- HMR support; -- access to browser/expect instances in the browser's DevTools for convenient debugging; -- log display in the terminal to enhance comfort and speed up development. +- isolated testing of React components in a real browser; +- stability and reproducibility of test results compared to JSDom; +- HMR support; +- access to browser/expect instances in the browser's DevTools for convenient debugging; +- log display in the terminal to enhance comfort and speed up development. Switch to Testplane and try the new feature yourself. If you encounter any problems, come to the [issue github](https://github.com/gemini-testing/testplane/issues) — we will definitely help you! diff --git a/i18n/en/docusaurus-plugin-content-docs/current/commands/mock/respond.mdx b/i18n/en/docusaurus-plugin-content-docs/current/commands/mock/respond.mdx index 05a1654..180ea10 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/commands/mock/respond.mdx +++ b/i18n/en/docusaurus-plugin-content-docs/current/commands/mock/respond.mdx @@ -7,7 +7,8 @@ import Admonition from "@theme/Admonition"; Use the `respond` command to always reply with the same overwrite. - Also read the recipe "[How to Track and Intercept Network Requests and Responses][how-to-intercept-requests-and-responses]". + Also read the recipe "[How to Track and Intercept Network Requests and + Responses][how-to-intercept-requests-and-responses]". ## Usage {#usage} @@ -34,46 +35,57 @@ mock.respond(overwrites, { header, statusCode, fetchResponse }); ## Usage Examples {#examples} ```javascript -it('should demonstrate response overwrite with static data', async ({ browser }) => { - const mock = await browser.mock('https://todo-backend-express-knex.herokuapp.com/', { - method: 'get' +it("should demonstrate response overwrite with static data", async ({ browser }) => { + const mock = await browser.mock("https://todo-backend-express-knex.herokuapp.com/", { + method: "get", }); - mock.respond([{ - title: 'Injected (non) completed Todo', - order: null, - completed: false - }, { - title: 'Injected completed Todo', - order: null, - completed: true - }], { - statusCode: 200, - fetchResponse: true // default - }); - - await browser.url('https://todobackend.com/client/index.html?https://todo-backend-express-knex.herokuapp.com/'); - - await browser.$('#todo-list li').waitForExist(); - - const todoElements = await browser.$$('#todo-list li'); + mock.respond( + [ + { + title: "Injected (non) completed Todo", + order: null, + completed: false, + }, + { + title: "Injected completed Todo", + order: null, + completed: true, + }, + ], + { + statusCode: 200, + fetchResponse: true, // default + }, + ); + + await browser.url( + "https://todobackend.com/client/index.html?https://todo-backend-express-knex.herokuapp.com/", + ); + + await browser.$("#todo-list li").waitForExist(); + + const todoElements = await browser.$$("#todo-list li"); console.log(await Promise.all(todoElements.map(el => el.getText()))); // will output: "[ 'Injected (non) completed Todo', 'Injected completed Todo' ]" }); -it('should demonstrate response overwrite with dynamic data', async ({ browser }) => { - const mock = await browser.mock('https://todo-backend-express-knex.herokuapp.com/'); - - mock.respond((request) => { - if (request.body.username === 'test') { - return { ...request.body, foo: 'bar' }; - } - return request.body; - }, { - statusCode: () => 200, - headers: () => ({ foo: 'bar' }), - fetchResponse: false // do not fetch the actual response - }); +it("should demonstrate response overwrite with dynamic data", async ({ browser }) => { + const mock = await browser.mock("https://todo-backend-express-knex.herokuapp.com/"); + + mock.respond( + request => { + if (request.body.username === "test") { + return { ...request.body, foo: "bar" }; + } + return request.body; + }, + { + statusCode: () => 200, + headers: () => ({ foo: "bar" }), + fetchResponse: false, // do not fetch the actual response + }, + ); }); ``` diff --git a/i18n/en/docusaurus-plugin-content-docs/current/commands/mock/respondOnce.mdx b/i18n/en/docusaurus-plugin-content-docs/current/commands/mock/respondOnce.mdx index 2ea024e..78a1d7b 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/commands/mock/respondOnce.mdx +++ b/i18n/en/docusaurus-plugin-content-docs/current/commands/mock/respondOnce.mdx @@ -11,7 +11,8 @@ You can call `respondOnce` multiple times in succession. The responses will be u If you use only `respondOnce` and access the resource more times than `respondOnce` was called, then after exhausting the fake data, the request will start returning the original response from the resource. - Also read the recipe "[How to Track and Intercept Network Requests and Responses][how-to-intercept-requests-and-responses]". + Also read the recipe "[How to Track and Intercept Network Requests and + Responses][how-to-intercept-requests-and-responses]". ## Usage {#usage} diff --git a/i18n/en/docusaurus-plugin-content-docs/current/commands/overview.mdx b/i18n/en/docusaurus-plugin-content-docs/current/commands/overview.mdx index 5de7e23..11c807c 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/commands/overview.mdx +++ b/i18n/en/docusaurus-plugin-content-docs/current/commands/overview.mdx @@ -9,7 +9,9 @@ import Admonition from "@theme/Admonition"; ## Overview - Only commands for the latest version Testplane v8 and WebDriverIO v8 are described. Commands for older versions should be referenced in the WebDriverIO documentation (example for [WebDriverIO v7][webdriverio@7-api]). + Only commands for the latest version Testplane v8 and WebDriverIO v8 are described. Commands for + older versions should be referenced in the WebDriverIO documentation (example for [WebDriverIO + v7][webdriverio@7-api]). Since testplane is based on [WebDriverIO v8][webdriverio-api], all commands provided by WebDriverIO are available in it. @@ -19,7 +21,7 @@ However, the command descriptions on the [WebDriverIO][webdriverio-api] website - In WebDriverIO, the `browser` object exists in the global scope, whereas in testplane you need to either write `this.browser`: ```javascript -it("should test something", async function() { +it("should test something", async function () { const browser = this.browser; // test code... }); diff --git a/i18n/en/docusaurus-plugin-content-docs/current/guides/how-to-debug-test.mdx b/i18n/en/docusaurus-plugin-content-docs/current/guides/how-to-debug-test.mdx index 2b97dfd..01dd98b 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/guides/how-to-debug-test.mdx +++ b/i18n/en/docusaurus-plugin-content-docs/current/guides/how-to-debug-test.mdx @@ -48,8 +48,8 @@ testplane path/to/mytest.js --inspect ``` - In debug mode, only one worker process is started, and all tests are run in it. - Use this mode with the parameter _sessionsPerBrowser=1_ to debug tests one at a time. + In debug mode, only one worker process is started, and all tests are run in it. Use this mode + with the parameter _sessionsPerBrowser=1_ to debug tests one at a time. ## Keywords {#keywords} diff --git a/i18n/en/docusaurus-plugin-content-docs/current/guides/how-to-get-report.mdx b/i18n/en/docusaurus-plugin-content-docs/current/guides/how-to-get-report.mdx index 313d899..12b66c3 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/guides/how-to-get-report.mdx +++ b/i18n/en/docusaurus-plugin-content-docs/current/guides/how-to-get-report.mdx @@ -11,16 +11,34 @@ Total: 1812 Passed: 1792 Failed: 0 Skipped: 20 Retries: 47 Where: - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + +
StatusDescription
TotalTotal number of tests that testplane read from the file system during launch.
PassedNumber of tests that passed successfully.
FailedNumber of tests that failed.
SkippedNumber of tests that were skipped during the run.
RetriesTotal number of test retries that occurred during the run.
StatusDescription
TotalTotal number of tests that testplane read from the file system during launch.
PassedNumber of tests that passed successfully.
FailedNumber of tests that failed.
SkippedNumber of tests that were skipped during the run.
RetriesTotal number of test retries that occurred during the run.
However, this information may not be sufficient, so you can add the [stat-reporter][stat-reporter] plugin to your project. diff --git a/i18n/en/docusaurus-plugin-content-docs/current/guides/how-to-hide-scrollbars.mdx b/i18n/en/docusaurus-plugin-content-docs/current/guides/how-to-hide-scrollbars.mdx index f596518..e0ae6a6 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/guides/how-to-hide-scrollbars.mdx +++ b/i18n/en/docusaurus-plugin-content-docs/current/guides/how-to-hide-scrollbars.mdx @@ -49,7 +49,9 @@ If scrollbars appear in screenshots in the Chrome browser, they can be disabled To do this, add the [hermione-hide-scrollbars][hermione-hide-scrollbars] plugin to your project and specify in its settings the list of browsers for which you want to disable scrollbars in the tests. - Update the Chrome browser to version 72.1 or higher for this functionality to work in your tests. Earlier versions of Chrome do not support the _Emulation.setScrollbarsHidden_ command, which is used to disable the scrollbars. + Update the Chrome browser to version 72.1 or higher for this functionality to work in your + tests. Earlier versions of Chrome do not support the _Emulation.setScrollbarsHidden_ command, + which is used to disable the scrollbars. ## Keywords {#keywords} diff --git a/i18n/en/docusaurus-plugin-content-docs/current/guides/how-to-use-cdp.mdx b/i18n/en/docusaurus-plugin-content-docs/current/guides/how-to-use-cdp.mdx index ddd5229..f88b085 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/guides/how-to-use-cdp.mdx +++ b/i18n/en/docusaurus-plugin-content-docs/current/guides/how-to-use-cdp.mdx @@ -5,7 +5,8 @@ import Admonition from "@theme/Admonition"; ## Introduction {#preface} - Install testplane version 4 or higher in your project to use _Chrome DevTools Protocol (CDP)_ in testplane tests. + Install testplane version 4 or higher in your project to use _Chrome DevTools Protocol (CDP)_ in + testplane tests. The `WebDriver` protocol has been used in testplane for a long time, but the possibility of using [CDP][CDP] appeared only after migrating to _[WebdriverIO@7](https://webdriver.io/versions)_ in testplane version 4. @@ -86,7 +87,8 @@ module.exports = { ``` - Full CDP usage is only supported from **Chrome@77** and higher. This is due to the internal implementation in _webdriverio._ + Full CDP usage is only supported from **Chrome@77** and higher. This is due to the internal + implementation in _webdriverio._ ## What Capabilities Does CDP Provide {#what_does_cdp_give} diff --git a/i18n/en/docusaurus-plugin-content-docs/current/migrations/how-to-upgrade-hermione-to-4.mdx b/i18n/en/docusaurus-plugin-content-docs/current/migrations/how-to-upgrade-hermione-to-4.mdx index d0cd5c2..7cd9236 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/migrations/how-to-upgrade-hermione-to-4.mdx +++ b/i18n/en/docusaurus-plugin-content-docs/current/migrations/how-to-upgrade-hermione-to-4.mdx @@ -68,7 +68,10 @@ it("some test", async function ({ browser }) { ``` - In the "New" examples going forward, it is assumed that the hermione version is at least _4.9.0_. If you plan to use hermione _4+_ but at a lower version than _4.9.0_, you should still access the browser in tests through _this_, for example: _await this.browser.getText('.selector')_. + In the "New" examples going forward, it is assumed that the hermione version is at least + _4.9.0_. If you plan to use hermione _4+_ but at a lower version than _4.9.0_, you should still + access the browser in tests through _this_, for example: _await + this.browser.getText('.selector')_. #### Direct Result Instead of Object with value Key {#feature_direct_result} @@ -118,7 +121,7 @@ Using the [`browser.$`][browser-dollar] command, you can get an instance of the await elem.clearElement(); await elem.setValue('text'); - }); +}); ```` @@ -157,7 +160,7 @@ it('some test', async function() { timeoutMsg: 'still exists' }); - }); +}); ```` @@ -192,7 +195,7 @@ it('some test', async function() { const result = await component.isDisplayed(); - }); +}); ```` @@ -232,7 +235,9 @@ module.exports = { We also plan to add a separate button in the hermione GUI for switching to CDP mode to make it even easier. - * Currently, this is fully supported only in the _Chrome_ browser. * Retaking screenshots in this mode should only be done for debugging, as browsers in the pipeline run under _Linux_, which means page rendering will differ and tests in the pull request will fail with diffs. + * Currently, this is fully supported only in the _Chrome_ browser. * Retaking screenshots in + this mode should only be done for debugging, as browsers in the pipeline run under _Linux_, + which means page rendering will differ and tests in the pull request will fail with diffs. ### API for Network Request Stubbing {#feature_api_to_mock_network} @@ -242,7 +247,8 @@ The new version provides the ability to stub or override the responses of your s Read more about all the features in the "How to Track and Intercept Network Requests and Responses" guide. - Currently, this functionality only works in _Chrome DevTools Protocol (CDP)_ mode, which only works in _Chrome_ and _Firefox Nightly_. + Currently, this functionality only works in _Chrome DevTools Protocol (CDP)_ mode, which only + works in _Chrome_ and _Firefox Nightly_. ### Browser Configuration in the Config {#browsers_config} diff --git a/i18n/en/docusaurus-plugin-content-docs/current/migrations/how-to-upgrade-hermione-to-5.mdx b/i18n/en/docusaurus-plugin-content-docs/current/migrations/how-to-upgrade-hermione-to-5.mdx index 07dff59..cfae071 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/migrations/how-to-upgrade-hermione-to-5.mdx +++ b/i18n/en/docusaurus-plugin-content-docs/current/migrations/how-to-upgrade-hermione-to-5.mdx @@ -6,6 +6,7 @@ import Admonition from "@theme/Admonition"; If your project uses hermione version earlier than 4.x, please read “How to Upgrade hermione to Version 4.x” before upgrading to version 5.x. We recommend upgrading hermione in stages, ensuring at each stage that all project tests run correctly. + ## What Has Changed? {#what_is_new} diff --git a/i18n/en/docusaurus-plugin-content-docs/current/migrations/how-to-upgrade-hermione-to-6.mdx b/i18n/en/docusaurus-plugin-content-docs/current/migrations/how-to-upgrade-hermione-to-6.mdx index 08c29fa..d5a86a7 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/migrations/how-to-upgrade-hermione-to-6.mdx +++ b/i18n/en/docusaurus-plugin-content-docs/current/migrations/how-to-upgrade-hermione-to-6.mdx @@ -6,6 +6,7 @@ import Admonition from "@theme/Admonition"; If your project is using a hermione version earlier than 4.x, please first read "How to Upgrade hermione to Version 4.x" and "How to Upgrade hermione to Version 5.x". We recommend upgrading hermione in stages, ensuring each step that all project tests run correctly. + ## What Has Changed? {#what_is_new} @@ -35,7 +36,8 @@ module.exports = { ``` - This setting will not work if your project is using a very old browser version. It is guaranteed to work in Chrome, starting from version 101. + This setting will not work if your project is using a very old browser version. It is guaranteed + to work in Chrome, starting from version 101. ## Support {#support} diff --git a/i18n/en/docusaurus-plugin-content-docs/current/migrations/how-to-upgrade-hermione-to-7.mdx b/i18n/en/docusaurus-plugin-content-docs/current/migrations/how-to-upgrade-hermione-to-7.mdx index 2aa6065..16d3046 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/migrations/how-to-upgrade-hermione-to-7.mdx +++ b/i18n/en/docusaurus-plugin-content-docs/current/migrations/how-to-upgrade-hermione-to-7.mdx @@ -6,6 +6,7 @@ import Admonition from "@theme/Admonition"; If your project is using a hermione version earlier than 4.x, first read "How to Upgrade hermione to Version 4.x," "How to Upgrade hermione to Version 5.x," and "How to Upgrade hermione to Version 6.x." We recommend upgrading hermione in stages, ensuring each step that all project tests run correctly. + ## What Has Changed? {#what_is_new} diff --git a/i18n/en/docusaurus-plugin-content-docs/current/migrations/how-to-upgrade-hermione-to-8.mdx b/i18n/en/docusaurus-plugin-content-docs/current/migrations/how-to-upgrade-hermione-to-8.mdx index ba4d889..f23efe2 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/migrations/how-to-upgrade-hermione-to-8.mdx +++ b/i18n/en/docusaurus-plugin-content-docs/current/migrations/how-to-upgrade-hermione-to-8.mdx @@ -10,6 +10,7 @@ If your project is using a hermione version earlier than 4.x, first read: * "How to Upgrade hermione to Version 7.x". We recommend upgrading hermione in stages, ensuring each step that all project tests run correctly. + ## What Has Changed? {#what_is_new} @@ -48,29 +49,29 @@ In this major version, hermione no longer supports versions _Node.JS < 18.x_. ### Minor Changes {#minor_changes} -- Added REPL mode for step-by-step debugging of tests in all browsers (not only CDP) without restarting. -- Added a browser command [clearSession][hermione-clear-session] to clear session state: - - Deletes cookies; - - Clears local storage; - - Clears session storage. -- Added a browser command `openAndWait` with customizable wait options for page loads (by selector, custom predicate, network request, etc.). -- Added a CLI option `--devtools` to simplify switching between the two protocols (`devtools` and `webdriver`). -- Improved stack trace for `unhandled rejection` errors. -- Now [isolation][hermione-isolation] is enabled by default for Chrome >= 94. -- During the execution of the [assertView][hermione-assert-view] command, CSS animations on the page will be disabled by default. -- Implemented generation of a unique `X-Request-ID` header for each request in the browser. The header consists of `${TEST_X_REQ_ID}${DELIMITER}$BROWSER_X_REQ_ID}`, where: - - - `TEST_X_REQ_ID` - a unique UUID for each test run (including retries of the same test). This allows you to find all requests related to a single test run in the logs. - - `DELIMITER` - `__` separator between the test and request UUIDs. - - `BROWSER_X_REQ_ID` - a unique UUID for each browser request. +- Added REPL mode for step-by-step debugging of tests in all browsers (not only CDP) without restarting. +- Added a browser command [clearSession][hermione-clear-session] to clear session state: + - Deletes cookies; + - Clears local storage; + - Clears session storage. +- Added a browser command `openAndWait` with customizable wait options for page loads (by selector, custom predicate, network request, etc.). +- Added a CLI option `--devtools` to simplify switching between the two protocols (`devtools` and `webdriver`). +- Improved stack trace for `unhandled rejection` errors. +- Now [isolation][hermione-isolation] is enabled by default for Chrome >= 94. +- During the execution of the [assertView][hermione-assert-view] command, CSS animations on the page will be disabled by default. +- Implemented generation of a unique `X-Request-ID` header for each request in the browser. The header consists of `${TEST_X_REQ_ID}${DELIMITER}$BROWSER_X_REQ_ID}`, where: + + - `TEST_X_REQ_ID` - a unique UUID for each test run (including retries of the same test). This allows you to find all requests related to a single test run in the logs. + - `DELIMITER` - `__` separator between the test and request UUIDs. + - `BROWSER_X_REQ_ID` - a unique UUID for each browser request. A real example of a UUID is `2f31ffb7-369d-41f4-bbb8-77744615d2eb__e8d011d8-bb76-42b9-b80e-02f03b8d6fe1`. ### Patch Changes {#patch_changes} -- Fixed disabling animations in iframes for iOS when using [assertView][hermione-assert-view]. -- Eliminated reinitialization of browser sessions in workers. -- Fixed a bug where it was impossible to disable [isolation][hermione-isolation]. +- Fixed disabling animations in iframes for iOS when using [assertView][hermione-assert-view]. +- Eliminated reinitialization of browser sessions in workers. +- Fixed a bug where it was impossible to disable [isolation][hermione-isolation]. ## How to Migrate? {#how_to_move} diff --git a/i18n/en/docusaurus-plugin-content-docs/current/reference/testplane-events.mdx b/i18n/en/docusaurus-plugin-content-docs/current/reference/testplane-events.mdx index 04cb849..959fe55 100644 --- a/i18n/en/docusaurus-plugin-content-docs/current/reference/testplane-events.mdx +++ b/i18n/en/docusaurus-plugin-content-docs/current/reference/testplane-events.mdx @@ -54,7 +54,10 @@ Testplane then launches subprocesses (known as workers) in which all tests will The number of workers that testplane launches is regulated by the [workers][system-workers] parameter in the [system][system] section of the testplane config. When a new worker is launched, testplane triggers the [NEW_WORKER_PROCESS](#new_worker_process) event. - Testplane runs all tests in workers to avoid memory and CPU limitations on the master process. Once the number of tests completed in a worker reaches the value of [testsPerWorker][system-tests-per-worker], the worker stops, and a new worker is launched. Accordingly, the [NEW_WORKER_PROCESS](#new_worker_process) event is triggered again. + Testplane runs all tests in workers to avoid memory and CPU limitations on the master process. + Once the number of tests completed in a worker reaches the value of + [testsPerWorker][system-tests-per-worker], the worker stops, and a new worker is launched. + Accordingly, the [NEW_WORKER_PROCESS](#new_worker_process) event is triggered again. #### Test reading @@ -77,6 +80,7 @@ If a test fails with a critical error, testplane will: - request a new browser and link it to the new session. This is to ensure that a failure in a session during one test run does not affect the subsequent test runs. + After creating a new session, testplane proceeds to run the tests. All tests are executed in workers, but the actual starting and collecting of the test results is done in the master process. The master process triggers the [SUITE_BEGIN](#suite_begin) event for describe-blocks in the test file and [TEST_BEGIN](#test_begin) for it-blocks. If a test is disabled using helpers like [skip.in][skip-in] and others, the [TEST_PENDING](#test_pending) event is triggered. @@ -88,7 +92,9 @@ Once the relevant test files are read by the worker, the [AFTER_TESTS_READ](#aft The listed 3 events — [BEFORE_FILE_READ](#before_file_read), [AFTER_FILE_READ](#after_file_read), and [AFTER_TESTS_READ](#after_tests_read) will be triggered in the workers during the test runs every time workers receive new tests to run from the master process. Except when the corresponding test file has already been read by the worker before. After the first reading of any file, the worker caches it to avoid re-reading the test file next time. - Because one file may contain many tests. The test run is done per individual test, not per file. Therefore, at some point in time, a test from a file that already had another test run may be executed. In such cases, caching protects from unnecessary re-reading of the same files. + Because one file may contain many tests. The test run is done per individual test, not per file. + Therefore, at some point in time, a test from a file that already had another test run may be + executed. In such cases, caching protects from unnecessary re-reading of the same files. Before a test is run, the [NEW_BROWSER](#new_browser) event is triggered. However, this event will not be triggered for all tests, as the same browser can be used many times to launch tests (see the [sessionsPerBrowser][browser-sessions-per-browser] parameter). Also, in case of a critical test failure, the browser is recreated to prevent other tests in that browser from failing due to a system crash. In this case, the [NEW_BROWSER](#new_browser) event will be sent again. @@ -353,7 +359,7 @@ Click to see the code ```javascript -const parseConfig = require('./config'); +const parseConfig = require("./config"); module.exports = (testplane, opts) => { const pluginConfig = parseConfig(opts); @@ -363,12 +369,12 @@ module.exports = (testplane, opts) => { return; } - testplane.on(testplane.events.CLI, (cli) => { + testplane.on(testplane.events.CLI, cli => { // add the --repeat option cli.option( - '--repeat ', - 'how many times tests should be repeated regardless of the result', - (value) => parseNonNegativeInteger(value, 'repeat') + "--repeat ", + "how many times tests should be repeated regardless of the result", + value => parseNonNegativeInteger(value, "repeat"), ); }); @@ -401,7 +407,8 @@ No data is passed to the event handler. In the [INIT](#init) event handler, you can organize, for example, the launch of a dev server for your project. - A dev server is an [express][express]-like application that allows you to develop the frontend of the project. + A dev server is an [express][express]-like application that allows you to develop the frontend + of the project. Below is the shortest implementation. A more detailed example can be found in the section "[Automatic dev server startup](#usage_starting_dev_server)". @@ -1298,7 +1305,7 @@ An object of the following format is passed to the event handler: ```javascript { state, // String: the state that the screenshot reflects, e.g., plain, map-view, scroll-left, etc. - refImg; // Object: of type { path, size: { width, height } }, describing the reference screenshot + refImg; // Object: of type { path, size: { width, height } }, describing the reference screenshot } ``` @@ -1487,8 +1494,8 @@ Click to view the code **Plugin Code** ```javascript -const http = require('http'); -const parseConfig = require('./config'); +const http = require("http"); +const parseConfig = require("./config"); module.exports = (testplane, opts) => { const pluginConfig = parseConfig(opts); @@ -1500,19 +1507,19 @@ module.exports = (testplane, opts) => { let program; - testplane.on(testplane.events.CLI, (cli) => { + testplane.on(testplane.events.CLI, cli => { // need to save a reference to the commander instance (https://github.com/tj/commander.js), // to later check for the option program = cli; // add the --dev-server option to testplane, // so the user can explicitly specify when to start the dev server - cli.option('--dev-server', 'run dev-server'); + cli.option("--dev-server", "run dev-server"); }); testplane.on(testplane.events.INIT, () => { // the dev server can be started either by specifying the --dev-server option // when launching testplane, or in the plugin settings - const devServer = program && program.devServer || pluginConfig.devServer; + const devServer = (program && program.devServer) || pluginConfig.devServer; if (!devServer) { // if the dev server doesn't need to be started – exit @@ -1520,12 +1527,10 @@ module.exports = (testplane, opts) => { } // content served by the dev server - const content = '

Hello, World!

'; + const content = "

Hello, World!

"; // create the server and start listening on port 3000 - http - .createServer((req, res) => res.end(content)) - .listen(3000); + http.createServer((req, res) => res.end(content)).listen(3000); // at http://localhost:3000/index.html, the content will be:

Hello, World!

});