https://github.com/cerberus/pup
An example of puppeteer project with prescript
https://github.com/cerberus/pup
puppeteer typescript
Last synced: 4 months ago
JSON representation
An example of puppeteer project with prescript
- Host: GitHub
- URL: https://github.com/cerberus/pup
- Owner: Cerberus
- Created: 2019-03-02T10:14:00.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-12-11T02:30:39.000Z (over 4 years ago)
- Last Synced: 2024-12-23T18:52:43.271Z (4 months ago)
- Topics: puppeteer, typescript
- Language: TypeScript
- Homepage: https://medium.com/@SunCerberus/puppeteer-with-prescript-js-proxy-example-b53526d356fe
- Size: 426 KB
- Stars: 4
- Watchers: 2
- Forks: 2
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Pup
An example puppeteer project with prescript
### Highlights
🔥 Hot Steps Replacement: Reload test-code without rerunning from first-step.
👥 Test-parallelization: Run your tests in parallel and grouping to a report.
🤖 No Javascript skill Required: Simple and readable to implement a test-case. (But required for adding additional actions)
### Setup
Clone & fulfill cookie configs in `.env` file.
```
cp .env.template .env
```
Install packages.
```
npm ci
```### Development process
Run `tsc` to automatically compile ts to js when the file is updated.
```
npm run build:watch
```
Open a new terminal tab and run the test file. (e.g. `src/__tests__/google/search/desktop.ts`)
```
npm run dev dist/__tests__/google/search/desktop.js
```
an example source code:
```ts
app
.init()
.goto('https://www.google.com')
.search('input[name=q]', 'google')
```
after run the command above..
```
## Loading test and generating test plan...
Step 1. Init
Step 1.1. Create page
Deferred Step 1.2. Close browser
Step 2. Goto https://www.google.com
Step 3. Search input[name=q] google
Step 3.1. Type input[name=q] google
Step 3.2. Enter
* Test plan generated successfully!
```
See more how to use [prescript](https://prescript.netlify.com) and enjoy : )### Use querySelector to debug
```
document.querySelector('')
```### Use xPath to debug
```
document.evaluate('', document, null, XPathResult.ANY_TYPE, null).iterateNext()
```### Use querySelectorAll to expect
```
document.querySelectorAll('')
```### Test Parallelization
Run all test files
```
npm run test:all
```Run all test files with generating a report
```
npm run test:report
````allure-results` will be created.
### Generating report (html)
After run `npm run test:report`. To preview allure report by coding
```
npm run serve:report
```Build an `allure-report` for uploading.
```
npm run gen:report
```### References
- [puppeteer](https://pptr.dev)
- [prescript](https://prescript.netlify.com)