# Quality assurance

::references
  :::ref-github{link="https://github.com/retejs/rete-qa" title="Rete QA"}
  :::

  :::ref-external{link="https://playwright.dev/" title="Playwright"}
  :::
::

There are two kinds of tests in this project - unit and E2E

Unit tests are used to test individual modules within a package. While this approach is fast, it doesn't guarantee that the entire product functions correctly from a user's perspective.

On the other hand, E2E tests enable comprehensive testing of the product from the user's point of view. We rely on **Playwright** for E2E testing, which is integrated into `rete-qa` package and comes equipped with a set of UI tests for basic framework features.

Guidelines for writing tests:

- **keep it simple**: create tests that are easy to write and read
- **don't focus too much on code coverage metrics**: use them as reference but avoid drawing conclusions solely based on test coverage %
- **test one thing at a time**: this will help you locate issues more easily
- **cover edge cases**: ensures reliability of tests

## Rete QA tool

The main purpose of this tool is to conduct regression UI testing on different combinations of supported features, which are presented as individual packages and various integrations with UI frameworks.

::diagram{caption="Architecture" name="qa/index"}
::

[Playwright](https://playwright.dev){rel="nofollow"} serves as the underlying technology for this testing tool and enables it to conduct tests in three different browser types: **Chromium**, **Firefox**, **WebKit**.

Additionally, we test our framework on various versions of commonly used UI frameworks, such as Angular, Svelte, Vue.js, and React.js. This gives us **51** test runs across different environments as we have a matrix of browsers and framework versions

::rete-qa-sheet{:browsers="browsers" :stacks="stacks" title="Browser \ Stack"}
::

### Installation

```bash
npm i -g rete-qa
```

Don't forget to install the additional system dependencies as per the [Playwright's instructions](https://playwright.dev/docs/ci#introduction){rel="nofollow"}.

### Initialization

Run the command and wait until the projects are generated for various frameworks and their dependencies are installed

```bash
rete-qa init --deps-alias dependencies.json
```

where `dependencies.json` (optional) is a JSON file, which should contain a mapping of dependencies

Dependencies are typically installed from npmjs using `latest` tag, but you can specify a different version by providing `name@version` or path to the tarball. For example, you can substitute a plugin with your own version of the plugin that has not yet been published

```json
{
  "my-rete-plugin": "../my-plugin/my-rete-plugin-1.0.0.tgz"
}
```

### Run tests

Run the tests for provided stacks (**React.js**, **Vue.js**, **Angular**, **Svelte**) and different browsers (**Chromium**, **Firefox**, **WebKit**)

```bash
rete-qa test
```