Skip to content

Commit 0d093af

Browse files
author
rocketraccoon
committed
feat(testing-library): testplane testing library
1 parent d6e2f53 commit 0d093af

File tree

12 files changed

+15559
-0
lines changed

12 files changed

+15559
-0
lines changed

.github/workflows/ci.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
branches: [master]
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
test:
15+
name: Run tests on Node.js ${{ matrix.node-version }}
16+
runs-on: self-hosted-arc
17+
18+
strategy:
19+
matrix:
20+
node-version: [18, 20, 22, 24]
21+
fail-fast: false
22+
23+
steps:
24+
- name: Checkout code
25+
uses: actions/checkout@v4
26+
27+
- name: Setup Node.js ${{ matrix.node-version }}
28+
uses: actions/setup-node@v4
29+
with:
30+
node-version: ${{ matrix.node-version }}
31+
cache: "npm"
32+
33+
- name: Install dependencies
34+
run: npm ci
35+
36+
- name: Run lint
37+
run: npm run lint
38+
39+
- name: Check formatting
40+
run: npm run check-formatting
41+
42+
- name: Run build
43+
run: npm run build

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules
2+
build
3+
tmp
4+
.vscode
5+
.idea

.prettierignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.idea
2+
build
3+
LICENSE
4+
package.json
5+
package-lock.json
6+
*.md
7+
.gitignore
8+
.nvmrc
9+
.prettierignore
10+
.github

.prettierrc.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module.exports = {
2+
printWidth: 120,
3+
useTabs: false,
4+
tabWidth: 4,
5+
semi: true,
6+
singleQuote: false,
7+
trailingComma: "all",
8+
bracketSpacing: true,
9+
arrowParens: "avoid",
10+
};

LICENSE

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015 YANDEX LLC
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of
6+
this software and associated documentation files (the "Software"), to deal in
7+
the Software without restriction, including without limitation the rights to
8+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9+
the Software, and to permit persons to whom the Software is furnished to do so,
10+
subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Testplane testing library
2+
3+
## Introduction
4+
[Testing-library](https://testing-library.com/) is a collection of tools for testing web application user interfaces, focused on creating reliable and maintainable tests by emphasizing user behavior. The main advantage of `testing-library` is its focus on interaction with interface elements. And in testplane, you can use the element search methods provided by the `testing-library` itself.
5+
6+
## Connection
7+
8+
1. Install the npm package `@testplane/testing-library`
9+
```shell
10+
npm i -D @testplane/testing-library
11+
```
12+
13+
2. Include it in the Testplane config in the `prepareBrowser` section:
14+
```js
15+
// .testplane.conf.js
16+
const { setupBrowser } = require("@testplane/testing-library");
17+
18+
module.exports = {
19+
prepareBrowser(browser) {
20+
setupBrowser(browser);
21+
},
22+
23+
// other Testplane settings...
24+
};
25+
```
26+
27+
## Usage
28+
29+
After configuring, you will be able to use the search by selectors from `testing-library`, as described in the [official documentation](https://testing-library.com/docs/queries/about/). For example, searching for an element by its text:
30+
31+
```js
32+
it("example", async ({ browser }) => {
33+
await browser.url("https://github.com/");
34+
35+
const newRepoButton = await browser.getByText("New");
36+
37+
await newRepoButton.click();
38+
});
39+
40+
41+
```
42+
43+
This feature will also be available in the context of found elements:
44+
45+
```js
46+
it("example", async ({ browser }) => {
47+
await browser.url("https://github.com/");
48+
49+
const sidebar = await browser.$(".dashboard-sidebar");
50+
const newRepoButton = await sidebar.getByText("New");
51+
52+
await newRepoButton.click();
53+
});
54+
```

eslint.config.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const js = require("@eslint/js");
2+
const globals = require("globals");
3+
const tseslint = require("typescript-eslint");
4+
const { defineConfig } = require("eslint/config");
5+
6+
module.exports = defineConfig([
7+
{
8+
ignores: ["node_modules/**", "build/**", "eslint.config.js"],
9+
},
10+
{
11+
files: ["**/*.{js,mjs,cjs,ts}"],
12+
plugins: { js },
13+
extends: ["js/recommended"],
14+
},
15+
{
16+
files: ["**/*.{js,mjs,cjs,ts}"],
17+
languageOptions: {
18+
globals: globals.node,
19+
},
20+
},
21+
tseslint.configs.recommended,
22+
]);

0 commit comments

Comments
 (0)