Skip to content

Commit

Permalink
docs(node): add mocking (#327)
Browse files Browse the repository at this point in the history
  • Loading branch information
stoffeastrom committed Aug 28, 2018
1 parent 8b81fab commit af93a88
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions docs/node.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,21 @@ npx aw -c ./path/to/aw.config.js -w --coverage
and start testing. It will only rerun affected tests and generate coverage accordingly.
Add files, remove files as you go and change your tests to rapidly build up a test coverage.

## Mocking

Built-in mocking. You can mock globally via the [**mocks**](#mocks) option or locally by using:

```javascript
const [FancyButton] = aw.mock(
[ // Mock components
['**/react/src/button.js', '() => (<span>hhhhh</span>)']
],
// Require components
['../src/fancy-button']);
```

Look at the React [example](https://github.com/qlik-oss/after-work.js/tree/master/examples/react) and especially [**here**](https://github.com/qlik-oss/after-work.js/blob/master/examples/react/test/fancy-button.spec.js) for more details.

## Snapshot Testing

We are using the awesome 📸 [**jest-snapshot**](https://github.com/facebook/jest/tree/master/packages/jest-snapshot) package.
Expand Down Expand Up @@ -48,6 +63,9 @@ describe('button', () => {

When using the preset-env option. A screenshot assertion plugin is added to Chai. This allows comparisons of images.

<details><summary>Example</summary>
<p>

```javascript
describe('screenshot', () => {
it('image should be equal', async () => {
Expand All @@ -60,6 +78,9 @@ describe('screenshot', () => {
});
```

</p>
</details>

## Options

### --presetEnv
Expand Down

0 comments on commit af93a88

Please sign in to comment.