├── .gitignore ├── .npmignore ├── .prettierrc ├── LICENSE ├── README.md ├── package-lock.json ├── package.json ├── src └── index.ts ├── tsconfig.json └── tslint.json /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | /lib -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | src 2 | tsconfig.json 3 | tslint.json 4 | .prettierrc -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "useTabs": false, 3 | "printWidth": 120, 4 | "tabWidth": 2, 5 | "singleQuote": true, 6 | "trailingComma": "all" 7 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Yevhen 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, 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, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Stand With Ukraine](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/banner-direct-single.svg)](https://vshymanskyy.github.io/StandWithUkraine) 2 | 3 | # Expected Condition 4 | 5 | > expected-condition-playwright is a Node.js library for [Playwright](https://github.com/microsoft/playwright) and [Puppeteer](https://github.com/puppeteer/puppeteer) that supplies a set of common conditions that provides functionalities to wait for certain conditions till a defined task is complete. 6 | 7 | ## Table of Contents 8 | 9 | - [Expected Condition](#expected-condition) 10 | - [Table of Contents](#table-of-contents) 11 | - [Getting Started](#getting-started) 12 | - [Installation](#installation) 13 | - [Import and usage](#import-and-usage) 14 | - [Types of Expected Conditions](#types-of-expected-conditions) 15 | - [attributeValueToBe](#attributevaluetobe) 16 | - [attributeValueContains](#attributevaluecontains) 17 | - [attributeToBeNotEmpty](#attributetobenotempty) 18 | - [numberOfElementsToBe](#numberofelementstobe) 19 | - [invisibilityOf](#invisibilityof) 20 | - [textToBePresentInElement](#texttobepresentinelement) 21 | - [textToBePresentInElementValue](#texttobepresentinelementvalue) 22 | - [elementToBeClickable](#elementtobeclickable) 23 | - [elementToBeSelected](#elementtobeselected) 24 | - [titleEquals](#titleequals) 25 | - [titleContains](#titlecontains) 26 | - [urlEquals](#urlequals) 27 | - [urlContains](#urlcontains) 28 | - [License](#license) 29 | 30 | ## Getting Started 31 | 32 | ### Installation 33 | 34 | To use expected-condition-playwright in your project, run: 35 | 36 | ```bash 37 | npm i -D expected-condition-playwright 38 | ``` 39 | 40 | ### Import and usage 41 | 42 | **_TypeScript_** 43 | 44 | ```ts 45 | // Import ExpectedCondition class as EC shortcut 46 | import { ExpectedCondition as EC } from 'expected-condition-playwright'; 47 | 48 | // Simple selector 49 | const submitButton = 'button'; 50 | 51 | // Use page's waitForFunction method to provide the elementToBeClickable method to instruct a command to wait until the element is clickable by the selector 52 | await page.waitForFunction(EC.elementToBeClickable(submitButton), submitButton, { timeout: 5000 }); 53 | ``` 54 | 55 | **_JavaScript_** 56 | 57 | ```ts 58 | // Require ExpectedCondition class as EC shortcut 59 | const { ExpectedCondition: EC } = require('expected-condition-playwright'); 60 | 61 | // Simple selector 62 | const submitButton = 'button'; 63 | 64 | // Use page's waitForFunction method to provide the elementToBeClickable method to instruct a command to wait until the element is clickable by the selector 65 | await page.waitForFunction(EC.elementToBeClickable(submitButton), submitButton, { timeout: 5000 }); 66 | ``` 67 | 68 | ## Types of Expected Conditions 69 | 70 | ### attributeValueToBe 71 | 72 | An expectation for checking element with given selector has attribute with a specific value 73 | 74 | **_Usage_** 75 | 76 | ```ts 77 | const inputSelector = 'input[type=q]'; 78 | const expectedAttribute = 'type'; 79 | const expectedValue = 'q'; 80 | 81 | await page.waitForFunction( 82 | EC.attributeValueToBe([inputSelector, expectedAttribute, expectedValue]), 83 | [inputSelector, expectedAttribute, expectedValue], 84 | { timeout: 5000 }, 85 | ); 86 | ``` 87 | 88 | ### attributeValueContains 89 | 90 | An expectation for checking element with given selector has attribute which contains a specific value 91 | 92 | **_Usage_** 93 | 94 | ```ts 95 | const inputSelector = 'input[type=que]'; 96 | const expectedAttribute = 'type'; 97 | const expectedValue = 'q'; 98 | 99 | await page.waitForFunction( 100 | EC.attributeValueContains([inputSelector, expectedAttribute, expectedValue]), 101 | [inputSelector, expectedAttribute, expectedValue], 102 | { timeout: 5000 }, 103 | ); 104 | ``` 105 | 106 | ### attributeToBeNotEmpty 107 | 108 | An expectation for checking element with given selector any non empty value for given attribute 109 | 110 | **_Usage_** 111 | 112 | ```ts 113 | const inputSelector = 'input[type=que]'; 114 | const expectedAttribute = 'type'; 115 | 116 | await page.waitForFunction( 117 | EC.attributeValueContains([inputSelector, expectedAttribute]), 118 | [inputSelector, expectedAttribute], 119 | { timeout: 5000 }, 120 | ); 121 | ``` 122 | 123 | ### numberOfElementsToBe 124 | 125 | An expectation for checking number of elements with given selector 126 | 127 | **_Usage_** 128 | 129 | ```ts 130 | const links = 'a'; 131 | const expectedNumber = '12'; 132 | 133 | await page.waitForFunction(EC.numberOfElementsToBe([links, expectedNumber]), [links, expectedNumber], { 134 | timeout: 5000, 135 | }); 136 | ``` 137 | 138 | ### invisibilityOf 139 | 140 | An expectation for checking the element to be invisible 141 | 142 | **_Usage_** 143 | 144 | ```ts 145 | const link = 'a'; 146 | 147 | await page.waitForFunction(EC.invisibilityOf(link), links, { timeout: 5000 }); 148 | ``` 149 | 150 | ### textToBePresentInElement 151 | 152 | An expectation for checking if the given text is present in the specified element. 153 | 154 | **_Usage_** 155 | 156 | ```ts 157 | const logInButton = 'button'; 158 | const expectedText = 'Log in'; 159 | 160 | await page.waitForFunction(EC.textToBePresentInElement([logInButton, expectedText]), [logInButton, expectedText], { 161 | timeout: 5000, 162 | }); 163 | ``` 164 | 165 | ### textToBePresentInElementValue 166 | 167 | An expectation for checking if the given text is present in the specified elements value attribute. 168 | 169 | **_Usage_** 170 | 171 | ```ts 172 | const userField = 'input'; 173 | const expectedValue = 'John'; 174 | 175 | await page.waitForFunction(EC.textToBePresentInElementValue([userField, expectedValue]), [userField, expectedValue], { 176 | timeout: 5000, 177 | }); 178 | ``` 179 | 180 | ### elementToBeClickable 181 | 182 | An expectation for checking the element is visible and enabled such that you can click it. 183 | 184 | **_Usage_** 185 | 186 | ```ts 187 | const nextButton = 'button'; 188 | 189 | await page.waitForFunction(EC.elementToBeClickable(nextButton), nextButton, { timeout: 5000 }); 190 | ``` 191 | 192 | ### elementToBeSelected 193 | 194 | An expectation for checking the element is visible and enabled such that you can click it. 195 | 196 | **_Usage_** 197 | 198 | ```ts 199 | const checkbox = 'input'; 200 | 201 | await page.waitForFunction(EC.elementToBeSelected(checkbox), checkbox, { timeout: 5000 }); 202 | ``` 203 | 204 | ### titleEquals 205 | 206 | An expectation for checking the title of a page. 207 | 208 | **_Usage_** 209 | 210 | ```ts 211 | const expectedTitle = 'Playwright'; 212 | 213 | await page.waitForFunction(EC.titleEquals(expectedTitle), expectedTitle, { timeout: 5000 }); 214 | ``` 215 | 216 | ### titleContains 217 | 218 | An expectation for checking that the title contains a case-sensitive substring 219 | 220 | **_Usage_** 221 | 222 | ```ts 223 | const expectedTitle = 'Play'; 224 | 225 | await page.waitForFunction(EC.titleContains(expectedTitle), expectedTitle, { timeout: 5000 }); 226 | ``` 227 | 228 | ### urlEquals 229 | 230 | An expectation for the URL of the current page to be a specific url. 231 | 232 | **_Usage_** 233 | 234 | ```ts 235 | const expectedUrl = 'http://github.com/'; 236 | 237 | await page.waitForFunction(EC.urlEquals(expectedUrl), expectedUrl, { timeout: 5000 }); 238 | ``` 239 | 240 | ### urlContains 241 | 242 | An expectation for the URL of the current page to contain specific text. 243 | 244 | **_Usage_** 245 | 246 | ```ts 247 | const expectedUrl = '.com'; 248 | 249 | await page.waitForFunction(EC.urlContains(expectedUrl), expectedUrl, { timeout: 5000 }); 250 | ``` 251 | 252 | ## License 253 | 254 | expected-condition-playwright is [MIT licensed](./LICENSE). 255 | -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "expected-condition-playwright", 3 | "version": "1.0.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "@babel/code-frame": { 8 | "version": "7.10.4", 9 | "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.10.4.tgz", 10 | "integrity": "sha512-vG6SvB6oYEhvgisZNFRmRCUkLz11c7rp+tbNTynGqc6mS1d5ATd/sGyV6W0KZZnXRKMTzZDRgQT3Ou9jhpAfUg==", 11 | "dev": true, 12 | "requires": { 13 | "@babel/highlight": "^7.10.4" 14 | } 15 | }, 16 | "@babel/helper-validator-identifier": { 17 | "version": "7.10.4", 18 | "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.10.4.tgz", 19 | "integrity": "sha512-3U9y+43hz7ZM+rzG24Qe2mufW5KhvFg/NhnNph+i9mgCtdTCtMJuI1TMkrIUiK7Ix4PYlRF9I5dhqaLYA/ADXw==", 20 | "dev": true 21 | }, 22 | "@babel/highlight": { 23 | "version": "7.10.4", 24 | "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.10.4.tgz", 25 | "integrity": "sha512-i6rgnR/YgPEQzZZnbTHHuZdlE8qyoBNalD6F+q4vAFlcMEcqmkoG+mPqJYJCo63qPf74+Y1UZsl3l6f7/RIkmA==", 26 | "dev": true, 27 | "requires": { 28 | "@babel/helper-validator-identifier": "^7.10.4", 29 | "chalk": "^2.0.0", 30 | "js-tokens": "^4.0.0" 31 | } 32 | }, 33 | "@types/node": { 34 | "version": "14.0.27", 35 | "resolved": "https://registry.npmjs.org/@types/node/-/node-14.0.27.tgz", 36 | "integrity": "sha512-kVrqXhbclHNHGu9ztnAwSncIgJv/FaxmzXJvGXNdcCpV1b8u1/Mi6z6m0vwy0LzKeXFTPLH0NzwmoJ3fNCIq0g==", 37 | "dev": true, 38 | "optional": true 39 | }, 40 | "@types/yauzl": { 41 | "version": "2.9.1", 42 | "resolved": "https://registry.npmjs.org/@types/yauzl/-/yauzl-2.9.1.tgz", 43 | "integrity": "sha512-A1b8SU4D10uoPjwb0lnHmmu8wZhR9d+9o2PKBQT2jU5YPTKsxac6M2qGAdY7VcL+dHHhARVUDmeg0rOrcd9EjA==", 44 | "dev": true, 45 | "optional": true, 46 | "requires": { 47 | "@types/node": "*" 48 | } 49 | }, 50 | "agent-base": { 51 | "version": "6.0.1", 52 | "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.1.tgz", 53 | "integrity": "sha512-01q25QQDwLSsyfhrKbn8yuur+JNw0H+0Y4JiGIKd3z9aYk/w/2kxD/Upc+t2ZBBSUNff50VjPsSW2YxM8QYKVg==", 54 | "dev": true, 55 | "requires": { 56 | "debug": "4" 57 | } 58 | }, 59 | "ansi-styles": { 60 | "version": "3.2.1", 61 | "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", 62 | "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", 63 | "dev": true, 64 | "requires": { 65 | "color-convert": "^1.9.0" 66 | } 67 | }, 68 | "arg": { 69 | "version": "4.1.3", 70 | "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", 71 | "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", 72 | "dev": true 73 | }, 74 | "argparse": { 75 | "version": "1.0.10", 76 | "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", 77 | "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", 78 | "dev": true, 79 | "requires": { 80 | "sprintf-js": "~1.0.2" 81 | } 82 | }, 83 | "async-limiter": { 84 | "version": "1.0.1", 85 | "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.1.tgz", 86 | "integrity": "sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ==", 87 | "dev": true 88 | }, 89 | "balanced-match": { 90 | "version": "1.0.0", 91 | "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", 92 | "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", 93 | "dev": true 94 | }, 95 | "brace-expansion": { 96 | "version": "1.1.11", 97 | "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", 98 | "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", 99 | "dev": true, 100 | "requires": { 101 | "balanced-match": "^1.0.0", 102 | "concat-map": "0.0.1" 103 | } 104 | }, 105 | "buffer-crc32": { 106 | "version": "0.2.13", 107 | "resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz", 108 | "integrity": "sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI=", 109 | "dev": true 110 | }, 111 | "buffer-from": { 112 | "version": "1.1.1", 113 | "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", 114 | "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", 115 | "dev": true 116 | }, 117 | "builtin-modules": { 118 | "version": "1.1.1", 119 | "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", 120 | "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=", 121 | "dev": true 122 | }, 123 | "chalk": { 124 | "version": "2.4.2", 125 | "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", 126 | "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", 127 | "dev": true, 128 | "requires": { 129 | "ansi-styles": "^3.2.1", 130 | "escape-string-regexp": "^1.0.5", 131 | "supports-color": "^5.3.0" 132 | } 133 | }, 134 | "color-convert": { 135 | "version": "1.9.3", 136 | "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", 137 | "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", 138 | "dev": true, 139 | "requires": { 140 | "color-name": "1.1.3" 141 | } 142 | }, 143 | "color-name": { 144 | "version": "1.1.3", 145 | "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", 146 | "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", 147 | "dev": true 148 | }, 149 | "commander": { 150 | "version": "2.20.3", 151 | "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", 152 | "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", 153 | "dev": true 154 | }, 155 | "concat-map": { 156 | "version": "0.0.1", 157 | "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", 158 | "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", 159 | "dev": true 160 | }, 161 | "debug": { 162 | "version": "4.1.1", 163 | "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", 164 | "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", 165 | "dev": true, 166 | "requires": { 167 | "ms": "^2.1.1" 168 | } 169 | }, 170 | "diff": { 171 | "version": "4.0.2", 172 | "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", 173 | "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", 174 | "dev": true 175 | }, 176 | "end-of-stream": { 177 | "version": "1.4.4", 178 | "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", 179 | "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", 180 | "dev": true, 181 | "requires": { 182 | "once": "^1.4.0" 183 | } 184 | }, 185 | "escape-string-regexp": { 186 | "version": "1.0.5", 187 | "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", 188 | "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", 189 | "dev": true 190 | }, 191 | "esprima": { 192 | "version": "4.0.1", 193 | "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", 194 | "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", 195 | "dev": true 196 | }, 197 | "extract-zip": { 198 | "version": "2.0.1", 199 | "resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-2.0.1.tgz", 200 | "integrity": "sha512-GDhU9ntwuKyGXdZBUgTIe+vXnWj0fppUEtMDL0+idd5Sta8TGpHssn/eusA9mrPr9qNDym6SxAYZjNvCn/9RBg==", 201 | "dev": true, 202 | "requires": { 203 | "@types/yauzl": "^2.9.1", 204 | "debug": "^4.1.1", 205 | "get-stream": "^5.1.0", 206 | "yauzl": "^2.10.0" 207 | } 208 | }, 209 | "fd-slicer": { 210 | "version": "1.1.0", 211 | "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.1.0.tgz", 212 | "integrity": "sha1-JcfInLH5B3+IkbvmHY85Dq4lbx4=", 213 | "dev": true, 214 | "requires": { 215 | "pend": "~1.2.0" 216 | } 217 | }, 218 | "fs.realpath": { 219 | "version": "1.0.0", 220 | "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", 221 | "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", 222 | "dev": true 223 | }, 224 | "get-stream": { 225 | "version": "5.1.0", 226 | "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-5.1.0.tgz", 227 | "integrity": "sha512-EXr1FOzrzTfGeL0gQdeFEvOMm2mzMOglyiOXSTpPC+iAjAKftbr3jpCMWynogwYnM+eSj9sHGc6wjIcDvYiygw==", 228 | "dev": true, 229 | "requires": { 230 | "pump": "^3.0.0" 231 | } 232 | }, 233 | "glob": { 234 | "version": "7.1.6", 235 | "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", 236 | "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", 237 | "dev": true, 238 | "requires": { 239 | "fs.realpath": "^1.0.0", 240 | "inflight": "^1.0.4", 241 | "inherits": "2", 242 | "minimatch": "^3.0.4", 243 | "once": "^1.3.0", 244 | "path-is-absolute": "^1.0.0" 245 | } 246 | }, 247 | "has-flag": { 248 | "version": "3.0.0", 249 | "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", 250 | "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", 251 | "dev": true 252 | }, 253 | "https-proxy-agent": { 254 | "version": "5.0.0", 255 | "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.0.tgz", 256 | "integrity": "sha512-EkYm5BcKUGiduxzSt3Eppko+PiNWNEpa4ySk9vTC6wDsQJW9rHSa+UhGNJoRYp7bz6Ht1eaRIa6QaJqO5rCFbA==", 257 | "dev": true, 258 | "requires": { 259 | "agent-base": "6", 260 | "debug": "4" 261 | } 262 | }, 263 | "inflight": { 264 | "version": "1.0.6", 265 | "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", 266 | "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", 267 | "dev": true, 268 | "requires": { 269 | "once": "^1.3.0", 270 | "wrappy": "1" 271 | } 272 | }, 273 | "inherits": { 274 | "version": "2.0.4", 275 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", 276 | "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", 277 | "dev": true 278 | }, 279 | "jpeg-js": { 280 | "version": "0.4.1", 281 | "resolved": "https://registry.npmjs.org/jpeg-js/-/jpeg-js-0.4.1.tgz", 282 | "integrity": "sha512-jA55yJiB5tCXEddos8JBbvW+IMrqY0y1tjjx9KNVtA+QPmu7ND5j0zkKopClpUTsaETL135uOM2XfcYG4XRjmw==", 283 | "dev": true 284 | }, 285 | "js-tokens": { 286 | "version": "4.0.0", 287 | "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", 288 | "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", 289 | "dev": true 290 | }, 291 | "js-yaml": { 292 | "version": "3.14.0", 293 | "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.0.tgz", 294 | "integrity": "sha512-/4IbIeHcD9VMHFqDR/gQ7EdZdLimOvW2DdcxFjdyyZ9NsbS+ccrXqVWDtab/lRl5AlUqmpBx8EhPaWR+OtY17A==", 295 | "dev": true, 296 | "requires": { 297 | "argparse": "^1.0.7", 298 | "esprima": "^4.0.0" 299 | } 300 | }, 301 | "make-error": { 302 | "version": "1.3.6", 303 | "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", 304 | "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", 305 | "dev": true 306 | }, 307 | "mime": { 308 | "version": "2.4.6", 309 | "resolved": "https://registry.npmjs.org/mime/-/mime-2.4.6.tgz", 310 | "integrity": "sha512-RZKhC3EmpBchfTGBVb8fb+RL2cWyw/32lshnsETttkBAyAUXSGHxbEJWWRXc751DrIxG1q04b8QwMbAwkRPpUA==", 311 | "dev": true 312 | }, 313 | "minimatch": { 314 | "version": "3.0.4", 315 | "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", 316 | "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", 317 | "dev": true, 318 | "requires": { 319 | "brace-expansion": "^1.1.7" 320 | } 321 | }, 322 | "minimist": { 323 | "version": "1.2.5", 324 | "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", 325 | "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", 326 | "dev": true 327 | }, 328 | "mkdirp": { 329 | "version": "0.5.5", 330 | "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", 331 | "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", 332 | "dev": true, 333 | "requires": { 334 | "minimist": "^1.2.5" 335 | } 336 | }, 337 | "ms": { 338 | "version": "2.1.2", 339 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", 340 | "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", 341 | "dev": true 342 | }, 343 | "once": { 344 | "version": "1.4.0", 345 | "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", 346 | "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", 347 | "dev": true, 348 | "requires": { 349 | "wrappy": "1" 350 | } 351 | }, 352 | "path-is-absolute": { 353 | "version": "1.0.1", 354 | "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", 355 | "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", 356 | "dev": true 357 | }, 358 | "path-parse": { 359 | "version": "1.0.6", 360 | "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", 361 | "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", 362 | "dev": true 363 | }, 364 | "pend": { 365 | "version": "1.2.0", 366 | "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", 367 | "integrity": "sha1-elfrVQpng/kRUzH89GY9XI4AelA=", 368 | "dev": true 369 | }, 370 | "playwright-core": { 371 | "version": "1.3.0", 372 | "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.3.0.tgz", 373 | "integrity": "sha512-g/KHXOZqmiyw6ZgdLQdU7gKAyI5Oo15R76022qi64RnrO01eFZZMWmq3J3GQr8Ah2monWK4GKr2MM1E3Tb25XQ==", 374 | "dev": true, 375 | "requires": { 376 | "debug": "^4.1.1", 377 | "extract-zip": "^2.0.0", 378 | "https-proxy-agent": "^5.0.0", 379 | "jpeg-js": "^0.4.0", 380 | "mime": "^2.4.4", 381 | "pngjs": "^5.0.0", 382 | "progress": "^2.0.3", 383 | "proxy-from-env": "^1.1.0", 384 | "rimraf": "^3.0.2", 385 | "ws": "^6.1.0" 386 | } 387 | }, 388 | "pngjs": { 389 | "version": "5.0.0", 390 | "resolved": "https://registry.npmjs.org/pngjs/-/pngjs-5.0.0.tgz", 391 | "integrity": "sha512-40QW5YalBNfQo5yRYmiw7Yz6TKKVr3h6970B2YE+3fQpsWcrbj1PzJgxeJ19DRQjhMbKPIuMY8rFaXc8moolVw==", 392 | "dev": true 393 | }, 394 | "prettier": { 395 | "version": "2.0.5", 396 | "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.0.5.tgz", 397 | "integrity": "sha512-7PtVymN48hGcO4fGjybyBSIWDsLU4H4XlvOHfq91pz9kkGlonzwTfYkaIEwiRg/dAJF9YlbsduBAgtYLi+8cFg==", 398 | "dev": true 399 | }, 400 | "progress": { 401 | "version": "2.0.3", 402 | "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", 403 | "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", 404 | "dev": true 405 | }, 406 | "proxy-from-env": { 407 | "version": "1.1.0", 408 | "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", 409 | "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==", 410 | "dev": true 411 | }, 412 | "pump": { 413 | "version": "3.0.0", 414 | "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", 415 | "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", 416 | "dev": true, 417 | "requires": { 418 | "end-of-stream": "^1.1.0", 419 | "once": "^1.3.1" 420 | } 421 | }, 422 | "resolve": { 423 | "version": "1.17.0", 424 | "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.17.0.tgz", 425 | "integrity": "sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w==", 426 | "dev": true, 427 | "requires": { 428 | "path-parse": "^1.0.6" 429 | } 430 | }, 431 | "rimraf": { 432 | "version": "3.0.2", 433 | "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", 434 | "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", 435 | "dev": true, 436 | "requires": { 437 | "glob": "^7.1.3" 438 | } 439 | }, 440 | "semver": { 441 | "version": "5.7.1", 442 | "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", 443 | "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", 444 | "dev": true 445 | }, 446 | "source-map": { 447 | "version": "0.6.1", 448 | "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", 449 | "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", 450 | "dev": true 451 | }, 452 | "source-map-support": { 453 | "version": "0.5.19", 454 | "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.19.tgz", 455 | "integrity": "sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw==", 456 | "dev": true, 457 | "requires": { 458 | "buffer-from": "^1.0.0", 459 | "source-map": "^0.6.0" 460 | } 461 | }, 462 | "sprintf-js": { 463 | "version": "1.0.3", 464 | "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", 465 | "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", 466 | "dev": true 467 | }, 468 | "supports-color": { 469 | "version": "5.5.0", 470 | "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", 471 | "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", 472 | "dev": true, 473 | "requires": { 474 | "has-flag": "^3.0.0" 475 | } 476 | }, 477 | "ts-node": { 478 | "version": "8.10.2", 479 | "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-8.10.2.tgz", 480 | "integrity": "sha512-ISJJGgkIpDdBhWVu3jufsWpK3Rzo7bdiIXJjQc0ynKxVOVcg2oIrf2H2cejminGrptVc6q6/uynAHNCuWGbpVA==", 481 | "dev": true, 482 | "requires": { 483 | "arg": "^4.1.0", 484 | "diff": "^4.0.1", 485 | "make-error": "^1.1.1", 486 | "source-map-support": "^0.5.17", 487 | "yn": "3.1.1" 488 | } 489 | }, 490 | "tslib": { 491 | "version": "1.13.0", 492 | "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.13.0.tgz", 493 | "integrity": "sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q==", 494 | "dev": true 495 | }, 496 | "tslint": { 497 | "version": "6.1.3", 498 | "resolved": "https://registry.npmjs.org/tslint/-/tslint-6.1.3.tgz", 499 | "integrity": "sha512-IbR4nkT96EQOvKE2PW/djGz8iGNeJ4rF2mBfiYaR/nvUWYKJhLwimoJKgjIFEIDibBtOevj7BqCRL4oHeWWUCg==", 500 | "dev": true, 501 | "requires": { 502 | "@babel/code-frame": "^7.0.0", 503 | "builtin-modules": "^1.1.1", 504 | "chalk": "^2.3.0", 505 | "commander": "^2.12.1", 506 | "diff": "^4.0.1", 507 | "glob": "^7.1.1", 508 | "js-yaml": "^3.13.1", 509 | "minimatch": "^3.0.4", 510 | "mkdirp": "^0.5.3", 511 | "resolve": "^1.3.2", 512 | "semver": "^5.3.0", 513 | "tslib": "^1.13.0", 514 | "tsutils": "^2.29.0" 515 | } 516 | }, 517 | "tslint-config-prettier": { 518 | "version": "1.18.0", 519 | "resolved": "https://registry.npmjs.org/tslint-config-prettier/-/tslint-config-prettier-1.18.0.tgz", 520 | "integrity": "sha512-xPw9PgNPLG3iKRxmK7DWr+Ea/SzrvfHtjFt5LBl61gk2UBG/DB9kCXRjv+xyIU1rUtnayLeMUVJBcMX8Z17nDg==", 521 | "dev": true 522 | }, 523 | "tsutils": { 524 | "version": "2.29.0", 525 | "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz", 526 | "integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==", 527 | "dev": true, 528 | "requires": { 529 | "tslib": "^1.8.1" 530 | } 531 | }, 532 | "typescript": { 533 | "version": "3.9.7", 534 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.7.tgz", 535 | "integrity": "sha512-BLbiRkiBzAwsjut4x/dsibSTB6yWpwT5qWmC2OfuCg3GgVQCSgMs4vEctYPhsaGtd0AeuuHMkjZ2h2WG8MSzRw==", 536 | "dev": true 537 | }, 538 | "wrappy": { 539 | "version": "1.0.2", 540 | "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", 541 | "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", 542 | "dev": true 543 | }, 544 | "ws": { 545 | "version": "6.2.1", 546 | "resolved": "https://registry.npmjs.org/ws/-/ws-6.2.1.tgz", 547 | "integrity": "sha512-GIyAXC2cB7LjvpgMt9EKS2ldqr0MTrORaleiOno6TweZ6r3TKtoFQWay/2PceJ3RuBasOHzXNn5Lrw1X0bEjqA==", 548 | "dev": true, 549 | "requires": { 550 | "async-limiter": "~1.0.0" 551 | } 552 | }, 553 | "yauzl": { 554 | "version": "2.10.0", 555 | "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz", 556 | "integrity": "sha1-x+sXyT4RLLEIb6bY5R+wZnt5pfk=", 557 | "dev": true, 558 | "requires": { 559 | "buffer-crc32": "~0.2.3", 560 | "fd-slicer": "~1.1.0" 561 | } 562 | }, 563 | "yn": { 564 | "version": "3.1.1", 565 | "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", 566 | "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", 567 | "dev": true 568 | } 569 | } 570 | } 571 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "expected-condition-playwright", 3 | "version": "1.0.1", 4 | "description": "expected-condition-playwright is a Node.js library with useful expected condition class", 5 | "main": "lib/index.js", 6 | "types": "lib/index.d.ts", 7 | "files": [ 8 | "lib/*" 9 | ], 10 | "scripts": { 11 | "prepare" : "npm run build", 12 | "prepublishOnly" : "npm run lint", 13 | "version" : "npm run format:write && git add -A src", 14 | "postversion" : "git push && git push --tags", 15 | "build": "tsc", 16 | "lint": "tslint -p tsconfig.json", 17 | "format:check": "prettier --check 'src/*.ts'", 18 | "format:write": "prettier --write 'src/*.ts'" 19 | }, 20 | "repository": { 21 | "type": "git", 22 | "url": "git+https://github.com/elaichenkov/expected-condition-playwright.git" 23 | }, 24 | "keywords": [ 25 | "playwright", 26 | "expectedConditions", 27 | "wait", 28 | "for", 29 | "expected", 30 | "conditions" 31 | ], 32 | "author": "Yevhen Laichenkov ", 33 | "license": "MIT", 34 | "bugs": { 35 | "url": "https://github.com/elaichenkov/expected-condition-playwright/issues" 36 | }, 37 | "homepage": "https://github.com/elaichenkov/expected-condition-playwright#readme", 38 | "devDependencies": { 39 | "prettier": "^2.0.5", 40 | "ts-node": "^8.10.2", 41 | "tslint": "^6.1.3", 42 | "tslint-config-prettier": "^1.18.0", 43 | "typescript": "^3.9.7" 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | export class ExpectedCondition { 2 | public static attributeValueToBe([_selector, _expectedAttribute, _expectedValue]: [string, string, string]) { 3 | return (args: string[]) => { 4 | const [selector, expectedAttribute, expectedValue] = args; 5 | const element: HTMLElement | null = document.querySelector(selector); 6 | 7 | if (element && element.getAttribute(expectedAttribute)) { 8 | return element.getAttribute(expectedAttribute) === expectedValue; 9 | } else { 10 | return false; 11 | } 12 | }; 13 | } 14 | 15 | public static attributeValueContains([_selector, _expectedAttribute, _expectedValue]: [string, string, string]) { 16 | return (args: string[]) => { 17 | const [selector, expectedAttribute, expectedValue] = args; 18 | const element: HTMLElement | null = document.querySelector(selector); 19 | 20 | if (element && element.getAttribute(expectedAttribute)) { 21 | return element.getAttribute(expectedAttribute)!.includes(expectedValue); 22 | } else { 23 | return false; 24 | } 25 | }; 26 | } 27 | 28 | public static attributeToBeNotEmpty([_selector, _expectedAttribute]: [string, string]) { 29 | return (args: string[]) => { 30 | const [selector, expectedAttribute] = args; 31 | const element: HTMLElement | null = document.querySelector(selector); 32 | 33 | return element && element.hasAttribute(expectedAttribute); 34 | }; 35 | } 36 | 37 | public static numberOfElementsToBe([_selector, _expectedNumber]: [string, string]) { 38 | return (args: string[]) => { 39 | const [selector, expectedNumber] = args; 40 | const elements: NodeList = document.querySelectorAll(selector); 41 | 42 | return elements.length === +expectedNumber; 43 | }; 44 | } 45 | 46 | public static invisibilityOf(_selector: string) { 47 | return (selector: string) => { 48 | const element: HTMLInputElement | HTMLElement | null = document.querySelector(selector); 49 | 50 | return !element; 51 | }; 52 | } 53 | 54 | public static textToBePresentInElement([_selector, _expectedText]: [string, string]) { 55 | return (args: string[]) => { 56 | const [selector, expectedText] = args; 57 | const element: HTMLElement | null = document.querySelector(selector); 58 | 59 | if (element && element.textContent) { 60 | return element.textContent.trim().includes(expectedText); 61 | } else { 62 | return false; 63 | } 64 | }; 65 | } 66 | 67 | public static textToBePresentInElementValue([_selector, _expectedValue]: [string, string]) { 68 | return (args: string[]): boolean => { 69 | const [selector, expectedValue] = args; 70 | const element: HTMLInputElement | null = document.querySelector(selector); 71 | 72 | if (element && element.value) { 73 | return element.value.includes(expectedValue); 74 | } else { 75 | return false; 76 | } 77 | }; 78 | } 79 | 80 | public static elementToBeClickable(_selector: string) { 81 | return (selector: string) => { 82 | const element: HTMLInputElement | null = document.querySelector(selector); 83 | 84 | return element && !element.disabled; 85 | }; 86 | } 87 | 88 | public static elementToBeSelected(_selector: string) { 89 | return (selector: string) => { 90 | const element: HTMLInputElement | null = document.querySelector(selector); 91 | 92 | return element && element.checked; 93 | }; 94 | } 95 | 96 | public static titleEquals(_expectedTitle: string) { 97 | return (expectedTitle: string) => document.title === expectedTitle; 98 | } 99 | 100 | public static titleContains(_expectedTitle: string) { 101 | return (expectedTitle: string) => document.title.includes(expectedTitle); 102 | } 103 | 104 | public static urlEquals(_expectedUrl: string) { 105 | return (expectedUrl: string) => window.location.href === expectedUrl; 106 | } 107 | 108 | public static urlContains(_expectedUrl: string) { 109 | return (expectedUrl: string) => window.location.href.includes(expectedUrl); 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | "declaration": true, 6 | "outDir": "./lib", 7 | "strict": true, 8 | "skipLibCheck": true, 9 | "lib": [ 10 | "es2016", 11 | "DOM" 12 | ] 13 | }, 14 | "include": ["src"], 15 | "exclude": ["node_modules"] 16 | } -------------------------------------------------------------------------------- /tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["tslint:recommended", "tslint-config-prettier"], 3 | "rules": { 4 | "variable-name": false 5 | } 6 | } 7 | --------------------------------------------------------------------------------