-
Notifications
You must be signed in to change notification settings - Fork 0
Testplane testing library #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
sonic16x
merged 9 commits into
master
from
users/rocketraccoon/TESTPLANE-635.publish-testing-library
Aug 1, 2025
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
9a2d1df
feat(testing-library): testplane testing library
4085683
feat(testing-library): testplane testing library # fix Readme
d191a86
feat(testing-library): testplane testing library # fix testplane version
32e055f
feat(testing-library): testplane testing library # fix badges
3c07c2c
feat(testing-library): testplane testing library # fix readme
257df1a
feat(testing-library): testplane testing library # fix readme
445950f
feat(testing-library): testplane testing library # fix import
8a4e2c9
feat(testing-library): testplane testing library # fix testplane version
0730f2e
feat(testing-library): testplane testing library # fix readme.md
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| name: CI | ||
|
|
||
| on: | ||
| push: | ||
| branches: [master] | ||
| pull_request: | ||
| branches: [master] | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| test: | ||
| name: Run tests on Node.js ${{ matrix.node-version }} | ||
| runs-on: self-hosted-arc | ||
|
|
||
| strategy: | ||
| matrix: | ||
| node-version: [18, 20, 22, 24] | ||
| fail-fast: false | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Node.js ${{ matrix.node-version }} | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: ${{ matrix.node-version }} | ||
| cache: "npm" | ||
|
|
||
| - name: Install dependencies | ||
| run: npm ci | ||
|
|
||
| - name: Run lint | ||
| run: npm run lint | ||
|
|
||
| - name: Check formatting | ||
| run: npm run check-formatting | ||
|
|
||
| - name: Run build | ||
| run: npm run build |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| node_modules | ||
| build | ||
| tmp | ||
| .vscode | ||
| .idea |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 22 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| .idea | ||
| build | ||
| LICENSE | ||
| package.json | ||
| package-lock.json | ||
| *.md | ||
| .gitignore | ||
| .nvmrc | ||
| .prettierignore | ||
| .github |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| module.exports = { | ||
| printWidth: 120, | ||
| useTabs: false, | ||
| tabWidth: 4, | ||
| semi: true, | ||
| singleQuote: false, | ||
| trailingComma: "all", | ||
| bracketSpacing: true, | ||
| arrowParens: "avoid", | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| The MIT License (MIT) | ||
|
|
||
| Copyright (c) 2015 YANDEX LLC | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
| this software and associated documentation files (the "Software"), to deal in | ||
| the Software without restriction, including without limitation the rights to | ||
| use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
| the Software, and to permit persons to whom the Software is furnished to do so, | ||
| subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
| FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
| COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
| IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
| CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| <p align="center"> | ||
| <picture> | ||
| <source media="(prefers-color-scheme: dark)" srcset="./docs/images/logo-light.svg" width="600"> | ||
| <source media="(prefers-color-scheme: light)" srcset="./docs/images/logo-dark.svg" width="600"> | ||
| <img alt="testplane testing library logo" src="./docs/images/logo-dark.svg" width="600"> | ||
| </picture> | ||
| </p> | ||
|
|
||
| <p align="center"> | ||
| <a href="https://testplane.io/docs/v8/guides/how-to-add-testing-library/"><img src="https://img.shields.io/badge/Docs-Website-6c47ff" alt="Total Downloads"></a> | ||
| <a href="https://www.npmjs.com/Яpackage/@testplane/testing-library"><img src="https://img.shields.io/npm/v/@testplane/testing-library.svg" alt="Latest Release"></a> | ||
| <a href="https://github.com/gemini-testing/testplane-testing-library/blob/master/LICENSE"><img src="https://img.shields.io/npm/l/@testplane/testing-library.svg" alt="License"></a> | ||
| <a href="https://t.me/testplane"><img src="https://img.shields.io/badge/community-chat-blue?logo=telegram" alt="Community Chat"></a> | ||
| </p> | ||
|
|
||
|
|
||
| ## Introduction | ||
| [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. | ||
|
|
||
| ## Installation | ||
|
|
||
| 1. Install the npm package `@testplane/testing-library`: | ||
| ```shell | ||
| npm i -D @testplane/testing-library | ||
| ``` | ||
|
|
||
| 2. Include it in the Testplane config in the `prepareBrowser` section: | ||
| ```js | ||
| // .testplane.conf.js | ||
| const { setupBrowser } = require("@testplane/testing-library"); | ||
|
|
||
| module.exports = { | ||
| prepareBrowser(browser) { | ||
| setupBrowser(browser); | ||
| }, | ||
|
|
||
| // other Testplane settings... | ||
| }; | ||
| ``` | ||
|
|
||
| If you are using TypeScript and experiencing issues with testing-library types, you may add the following line to your tsconfig.json | ||
|
|
||
| ```json | ||
| { | ||
| "compilerOptions": { | ||
| "types": [ | ||
| "@testplane/testing-library" | ||
| ] | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ## Usage | ||
|
|
||
| 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: | ||
|
|
||
| ```js | ||
| it("example", async ({ browser }) => { | ||
| await browser.url("https://github.com/"); | ||
|
|
||
| const newRepoButton = await browser.getByText("New"); | ||
|
|
||
| await newRepoButton.click(); | ||
| }); | ||
|
|
||
|
|
||
| ``` | ||
|
|
||
| This feature will also be available in the context of found elements: | ||
|
|
||
| ```js | ||
| it("example", async ({ browser }) => { | ||
| await browser.url("https://github.com/"); | ||
|
|
||
| const sidebar = await browser.$(".dashboard-sidebar"); | ||
| const newRepoButton = await sidebar.getByText("New"); | ||
|
|
||
| await newRepoButton.click(); | ||
| }); | ||
| ``` | ||
|
|
||
| Disclaimer: | ||
| All testing-library selectors return a promise and cannot be chained (like `browser.getByText().click()` — this is not possible). | ||
| Each testing-library selector must be awaited before performing any actions on it. | ||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| const js = require("@eslint/js"); | ||
| const globals = require("globals"); | ||
| const tseslint = require("typescript-eslint"); | ||
| const { defineConfig } = require("eslint/config"); | ||
|
|
||
| module.exports = defineConfig([ | ||
| { | ||
| ignores: ["node_modules/**", "build/**", "eslint.config.js"], | ||
| }, | ||
| { | ||
| files: ["**/*.{js,mjs,cjs,ts}"], | ||
| plugins: { js }, | ||
| extends: ["js/recommended"], | ||
| }, | ||
| { | ||
| files: ["**/*.{js,mjs,cjs,ts}"], | ||
| languageOptions: { | ||
| globals: globals.node, | ||
| }, | ||
| }, | ||
| tseslint.configs.recommended, | ||
| ]); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add a disclaimer here that as of now all testing-library selectors return a promise and cannot be chained (like browser.getByText().click() — this is not possible). Each testing-library selector must be awaited before performing any actions on it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed