Commit 8aab603
Michael Solomon
Push persisted interceptors to the end instead of ignore on remove (#2350)
Currently, if you do:
```
nock(..).get('/').reply(200).persist();
nock(..).get('/').reply(400); // this will never get called
```
The second interceptor won't get called ever.
But sometimes in tests (queue for examples), I want to do:
```
beforeAll(() => {
// some default behaviour
nock(..).get('/').reply(200).persist();
});
test('should ...', () => {
// test specific scenario for this same endpoint above
nock(..).get('/').reply(400)
})
```
I find a workaround using the body matcher function:
```
const createInterceptor = () => {
nock(..).get('/', () => {
createInterceptor();
return true;
})
.reply(200)
}
```
Which mimics the wanted behavior but is slower and way less elegant.1 parent 8a38f41 commit 8aab603
3 files changed
Lines changed: 27 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1002 | 1002 | | |
1003 | 1003 | | |
1004 | 1004 | | |
1005 | | - | |
| 1005 | + | |
1006 | 1006 | | |
1007 | 1007 | | |
1008 | 1008 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
113 | | - | |
| 113 | + | |
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
| |||
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
125 | 131 | | |
126 | 132 | | |
127 | 133 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
147 | 166 | | |
148 | 167 | | |
149 | 168 | | |
| |||
0 commit comments