Skip to content
This repository has been archived by the owner on Aug 6, 2023. It is now read-only.

Commit

Permalink
Fixes #19 - Allow executing puppeteer commands from mocha tests. (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
austinkelleher committed Sep 22, 2017
1 parent 3c7677d commit 8ca41d6
Show file tree
Hide file tree
Showing 8 changed files with 157 additions and 9,155 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
node_modules/
.cache/
static/
test/integration/mocha/static/*
!test/integration/mocha/static/.gitkeep

.mocha-puppeteer*/

Expand Down
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,25 @@ Note: Values provided in the `mochaOptions` field will be overridden by cli argu
For example, `mocha-puppeteer test/test.js --reporter dot` will override the `reporter` option in the
above config.

## Executing page commands from tests

[`puppeteer` page commands](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#class-page)
can be executed using `window.puppeteerCommand` from your tests. For example,
if you want to take a screenshot of the page:

```js
describe('screenshot test', function () {
it('should take a screenshot', async () => {
await window.puppeteerCommand({
type: 'screenshot', // The page command to run
args: [ { // The arguments that should be passed to the page command
path: './test.png'
} ]
})
})
})
```

## Advanced Usage

If you need to customize the page that is sent to the browser with your Mocha
Expand Down
Loading

0 comments on commit 8ca41d6

Please sign in to comment.