diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4280a7472..e224f83b7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -58,7 +58,7 @@ it into your editor][integrate prettier]. [integrate prettier]: https://prettier.io/docs/en/editors.html -If you don't want to integrate with your editor, you can run `npm run prettier` +If you don't want to integrate with your editor, you can run `npm run format:fix` instead. Semantic issues are checked with ESLint via `npm run lint`. diff --git a/README.md b/README.md index 8435fffe9..6d7e7f3b3 100644 --- a/README.md +++ b/README.md @@ -846,11 +846,24 @@ If you need to match requests only if certain request headers match, you can. ```js const scope = nock('http://api.myservice.com') + // Interceptors created after here will only match when the header `accept` equals `application/json`. .matchHeader('accept', 'application/json') .get('/') .reply(200, { data: 'hello world', }) + .get('/') + // Only this interceptor will match the header value `x-my-action` with `MyFirstAction` + .matchHeader('x-my-action', 'MyFirstAction') + .reply(200, { + data: 'FirstActionResponse', + }) + .get('/') + // Only this interceptor will match the header value `x-my-action` with `MySecondAction` + .matchHeader('x-my-action', 'MySecondAction') + .reply(200, { + data: 'SecondActionResponse', + }) ``` You can also use a regexp for the header body.