-
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
Changes from 8 commits
9a2d1df
4085683
d191a86
32e055f
3c07c2c
257df1a
445950f
8a4e2c9
0730f2e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another issue I've stumbled upon when trying to use this package is ENOENT error. Here's what I did:
Got this error:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed |
| 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 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| node_modules | ||
| build | ||
| tmp | ||
| .vscode | ||
| .idea |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 22 |
| 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 |
| 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", | ||
| }; |
| 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. |
| 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="300"> | ||
| <source media="(prefers-color-scheme: light)" srcset="./docs/images/logo-dark.svg" width="300"> | ||
| <img alt="testplane testing library logo" src="./docs/images/logo-dark.svg" width="300"> | ||
| </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... | ||
| }; | ||
| ``` | ||
|
|
||
| 3. ALso, if you are using typescript add to `tsconfig.json` -> `compilerOptions` -> `types` this line `@testplane/testing-library` | ||
|
|
||
| ```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: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed |
||
|
|
||
| ```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. | ||
| 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, | ||
| ]); |
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.
not related to this file: having
.nvmrcis a must. Right now after checking out this repo it's not clear which Node version should be used for development.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