Skip to content

Commit

Permalink
lint: fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
shadowusr committed Aug 5, 2024
1 parent c6ea7ca commit ed50fcc
Show file tree
Hide file tree
Showing 14 changed files with 157 additions and 103 deletions.
15 changes: 8 additions & 7 deletions i18n/en/docusaurus-plugin-content-blog/component-testing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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).

<Admonition type="warning" title="Currently, there are limitations">
- 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.
</Admonition>

### What additional features are supported?
Expand All @@ -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!
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import Admonition from "@theme/Admonition";
Use the `respond` command to always reply with the same overwrite.

<Admonition type="info">
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]".
</Admonition>

## Usage {#usage}
Expand All @@ -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
},
);
});
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.

<Admonition type="info">
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]".
</Admonition>

## Usage {#usage}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import Admonition from "@theme/Admonition";
## Overview

<Admonition type="warning">
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]).
</Admonition>

Since testplane is based on [WebDriverIO v8][webdriverio-api], all commands provided by WebDriverIO are available in it.
Expand All @@ -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...
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ testplane path/to/mytest.js --inspect
```

<Admonition type="info">
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.
</Admonition>

## Keywords {#keywords}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,34 @@ Total: 1812 Passed: 1792 Failed: 0 Skipped: 20 Retries: 47
Where:

<table>
<thead>
<tr><td>Status</td><td>Description</td></tr>
</thead>
<tbody>
<tr><td>Total</td><td>Total number of tests that testplane read from the file system during launch.</td></tr>
<tr><td>Passed</td><td>Number of tests that passed successfully.</td></tr>
<tr><td>Failed</td><td>Number of tests that failed.</td></tr>
<tr><td>Skipped</td><td>Number of tests that were skipped during the run.</td></tr>
<tr><td>Retries</td><td>Total number of test retries that occurred during the run.</td></tr>
</tbody>
<thead>
<tr>
<td>Status</td>
<td>Description</td>
</tr>
</thead>
<tbody>
<tr>
<td>Total</td>
<td>Total number of tests that testplane read from the file system during launch.</td>
</tr>
<tr>
<td>Passed</td>
<td>Number of tests that passed successfully.</td>
</tr>
<tr>
<td>Failed</td>
<td>Number of tests that failed.</td>
</tr>
<tr>
<td>Skipped</td>
<td>Number of tests that were skipped during the run.</td>
</tr>
<tr>
<td>Retries</td>
<td>Total number of test retries that occurred during the run.</td>
</tr>
</tbody>
</table>

However, this information may not be sufficient, so you can add the [stat-reporter][stat-reporter] plugin to your project.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.

<Admonition type="warning">
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.
</Admonition>

## Keywords {#keywords}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import Admonition from "@theme/Admonition";
## Introduction {#preface}

<Admonition type="warning">
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.
</Admonition>

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.
Expand Down Expand Up @@ -86,7 +87,8 @@ module.exports = {
```

<Admonition type="warning" title="Limitations">
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._
</Admonition>

## What Capabilities Does CDP Provide {#what_does_cdp_give}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ it("some test", async function ({ browser }) {
```

<Admonition type="warning">
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')_.
</Admonition>

#### Direct Result Instead of Object with value Key {#feature_direct_result}
Expand Down Expand Up @@ -118,7 +121,7 @@ Using the [`browser.$`][browser-dollar] command, you can get an instance of the
await elem.clearElement();
await elem.setValue('text');

});
});

````
</TabItem>
Expand Down Expand Up @@ -157,7 +160,7 @@ it('some test', async function() {
timeoutMsg: 'still exists'
});

});
});

````
</TabItem>
Expand Down Expand Up @@ -192,7 +195,7 @@ it('some test', async function() {

const result = await component.isDisplayed();

});
});

````
</TabItem>
Expand Down Expand Up @@ -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.
<Admonition type="warning">
* 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.
</Admonition>
### API for Network Request Stubbing {#feature_api_to_mock_network}
Expand All @@ -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.
<Admonition type="warning">
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_.
</Admonition>
### Browser Configuration in the Config {#browsers_config}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.

</Admonition>

## What Has Changed? {#what_is_new}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.

</Admonition>

## What Has Changed? {#what_is_new}
Expand Down Expand Up @@ -35,7 +36,8 @@ module.exports = {
```

<Admonition type="warning">
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.
</Admonition>

## Support {#support}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.

</Admonition>

## What Has Changed? {#what_is_new}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.

</Admonition>

## What Has Changed? {#what_is_new}
Expand Down Expand Up @@ -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}

Expand Down
Loading

0 comments on commit ed50fcc

Please sign in to comment.