Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cancerberosgx/jest-puppeteer-to-have
DOM selection rule-them-all, jest-puppeteer custom matcher
https://github.com/cancerberosgx/jest-puppeteer-to-have
Last synced: about 2 months ago
JSON representation
DOM selection rule-them-all, jest-puppeteer custom matcher
- Host: GitHub
- URL: https://github.com/cancerberosgx/jest-puppeteer-to-have
- Owner: cancerberoSgx
- License: mit
- Created: 2019-03-16T23:12:55.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-03-17T09:14:14.000Z (almost 6 years ago)
- Last Synced: 2024-11-09T12:12:10.464Z (2 months ago)
- Language: TypeScript
- Size: 555 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# jest-puppeteer-to-have
WIP
DOM selection rule-them-all, jest-puppeteer custom matcher.
Currently has two main tools:
* toHave for selection
* toEdit for modifications## Motivation
* have a rule-them-all matcher to assert on DOM so we can build more abstract/semantic matchers based on it
* A general HTML element query utility with emphasis on asserting on text, DOM, hierarchy with flexible API to define verbs, modes, mutiplicity, etc
* Has options to configure element selection and text extraction and value comparison.
* The only required configuration property is "selector".
* Passed on this other more-meaningful expects can be easily built, so is not an objective to have a simple/clear API but to be flexible enough for implement most cases with a single call## Usage
```sh
npm install -D jest-puppeteer-to-have
```Of course, you also need `jest`, `puppeteer`, `jest-puppeteer` installed and configured.
(very simple)
```ts
import 'jest-puppeteer-to-have'describe('test', ()=>{
beforeAll(async () => {
await page.goto('http://localhost:8080')
})
it('should get title', async () => {
await expect(page).not.toHave({
selector: 'body',
text: 'bar'
})
await expect(page).toEdit({
selector: 'body',
innerHTML: 'bar
',
})
await expect(page).toHave({
selector: 'body',
text: 'bar'
})
})
})
```## API
### ToHaveOptions
* [HTML](https://cancerberosgx.github.io/jest-puppeteer-to-have/api/interfaces/_tohave_types_.tohaveoptions.html)
* [Markdown](docs/api-md/interfaces/_tohave_types_.tohaveoptions.md)
* [TypeScript declarations](src/toHave/types.ts)
### ToEditOptions* [ToEditOptions (html)](https://cancerberosgx.github.io/jest-puppeteer-to-have/api/interfaces/_toedit_types_.toeditoptions.html)
* [ToEditOptions (markdown)](docs/api-md/interfaces/_toedit_types_.toeditoptions.md)
* [TypeScript declarations](src/toEdit/types.ts)### ToTriggerOptions
* [HTML](https://cancerberosgx.github.io/jest-puppeteer-to-have/api/interfaces/_totrigger_types_.totriggeroptions.html)
* [HTML](docs/api-md/interfaces/_totrigger_types_.totriggeroptions.md)
* [TypeScript declarations](src/toTrigger/types.ts)## TODO / IDEAS / QUESTIONS
* should we support events (i.e expect(page).toClick()...)