Skip to content

Commit

Permalink
update setup
Browse files Browse the repository at this point in the history
  • Loading branch information
LironEr committed Jun 4, 2022
1 parent 1f68b7b commit c130355
Showing 1 changed file with 48 additions and 48 deletions.
96 changes: 48 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,62 +27,62 @@ Zero config Mochawesome reporter for Cypress with screenshots attached to tests.
1. install cypress-mochawesome-reporter

```
npm i --save-dev cypress-mochawesome-reporter
```
```
npm i --save-dev cypress-mochawesome-reporter
```
or
or
```
yarn add -D cypress-mochawesome-reporter
```
```
yarn add -D cypress-mochawesome-reporter
```
2. Change cypress reporter & setup hooks
config file (`cypress.config.js` by default)

```js
const { defineConfig } = require('cypress');

module.exports = defineConfig({
reporter: 'cypress-mochawesome-reporter',
e2e: {
setupNodeEvents(on, config) {
require('cypress-mochawesome-reporter/plugin')(on);
},
},
});
```

If you are override `before:run` or `after:run` hooks, use this:

```js
const { defineConfig } = require('cypress');
const { beforeRunHook, afterRunHook } = require('cypress-mochawesome-reporter/lib');

module.exports = defineConfig({
reporter: 'cypress-mochawesome-reporter',
e2e: {
setupNodeEvents(on, config) {
on('before:run', async (details) => {
console.log('override before:run');
await beforeRunHook(details);
});

on('after:run', async () => {
console.log('override after:run');
await afterRunHook();
});
},
},
});
```
Edit config file (`cypress.config.js` by default)
```js
const { defineConfig } = require('cypress');
module.exports = defineConfig({
reporter: 'cypress-mochawesome-reporter',
e2e: {
setupNodeEvents(on, config) {
require('cypress-mochawesome-reporter/plugin')(on);
},
},
});
```
If you are override `before:run` or `after:run` hooks, use this:
```js
const { defineConfig } = require('cypress');
const { beforeRunHook, afterRunHook } = require('cypress-mochawesome-reporter/lib');
module.exports = defineConfig({
reporter: 'cypress-mochawesome-reporter',
e2e: {
setupNodeEvents(on, config) {
on('before:run', async (details) => {
console.log('override before:run');
await beforeRunHook(details);
});
on('after:run', async () => {
console.log('override after:run');
await afterRunHook();
});
},
},
});
```
3. Add to `cypress/support/e2e.js`
```javascript
import 'cypress-mochawesome-reporter/register';
```
```javascript
import 'cypress-mochawesome-reporter/register';
```
5. run cypress
Expand Down

0 comments on commit c130355

Please sign in to comment.