node-tdd 5.0.1 → 5.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -9,9 +9,7 @@ export default (input, modifiers) => {
|
|
|
9
9
|
const unknownModifiers = modifierNames
|
|
10
10
|
.filter((n) => typeof modifiers[n] !== 'function');
|
|
11
11
|
if (unknownModifiers.length !== 0) {
|
|
12
|
-
|
|
13
|
-
console.warn(`Unknown Modifier(s) detected: ${unknownModifiers.join(', ')}`);
|
|
14
|
-
return;
|
|
12
|
+
throw new Error(`Unknown Modifier(s) detected: ${unknownModifiers.join(', ')}`);
|
|
15
13
|
}
|
|
16
14
|
// eslint-disable-next-line no-param-reassign
|
|
17
15
|
delete parent[k];
|
|
@@ -98,7 +98,7 @@ export default (opts) => {
|
|
|
98
98
|
// convert 404 response code to 500
|
|
99
99
|
const destroyOriginal = req.destroy;
|
|
100
100
|
req.destroy = (err) => {
|
|
101
|
-
if (err
|
|
101
|
+
if (err?.status === 404 && err?.statusCode === 404 && err?.code === 'ERR_NOCK_NO_MATCH') {
|
|
102
102
|
// eslint-disable-next-line no-param-reassign
|
|
103
103
|
err.statusCode = 500;
|
|
104
104
|
// eslint-disable-next-line no-param-reassign
|
|
@@ -178,10 +178,9 @@ export default (opts) => {
|
|
|
178
178
|
scope.filteringRequestBody = (body) => {
|
|
179
179
|
if (anyFlagPresent(['magic', 'body'])) {
|
|
180
180
|
const idx = pendingMocks.findIndex((m) => m.idx === scopeIdx);
|
|
181
|
-
const requestBody = tryParseJson(body);
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
pendingMocks[idx].record.body = requestBodyStr;
|
|
181
|
+
const requestBody = nullAsString(tryParseJson(body));
|
|
182
|
+
if (!isEqual(scope.body, requestBody)) {
|
|
183
|
+
pendingMocks[idx].record.body = requestBody;
|
|
185
184
|
}
|
|
186
185
|
return scope.body;
|
|
187
186
|
}
|
|
@@ -215,6 +214,18 @@ export default (opts) => {
|
|
|
215
214
|
interceptor.delayBody(pendingMocks[idx].record.delayBody);
|
|
216
215
|
}
|
|
217
216
|
|
|
217
|
+
const hasSentBody = requestBodyString !== undefined;
|
|
218
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
219
|
+
const hasRecordBody = interceptor._requestBody !== undefined;
|
|
220
|
+
if (hasSentBody !== hasRecordBody) {
|
|
221
|
+
if (anyFlagPresent(['magic', 'body'])) {
|
|
222
|
+
pendingMocks[idx].record.body = nullAsString(tryParseJson(requestBodyString));
|
|
223
|
+
} else {
|
|
224
|
+
// eslint-disable-next-line no-param-reassign
|
|
225
|
+
interceptor.errorMessage = 'Recording body mismatch';
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
218
229
|
if (anyFlagPresent(['magic', 'headers'])) {
|
|
219
230
|
// add new headers
|
|
220
231
|
const reqheaders = {
|