@schmock/core 1.9.2 → 1.9.4
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.
package/package.json
CHANGED
|
@@ -365,9 +365,8 @@ describeFeature(feature, ({ Scenario }) => {
|
|
|
365
365
|
responses = await Promise.all(promises);
|
|
366
366
|
});
|
|
367
367
|
|
|
368
|
-
Then("all responses should have
|
|
368
|
+
Then("all responses should have valid processedAt timestamps", () => {
|
|
369
369
|
const timestamps = responses.map(r => r.body.processedAt);
|
|
370
|
-
// In fast test environments, timestamps might be the same, so just check they exist
|
|
371
370
|
expect(timestamps).toHaveLength(3);
|
|
372
371
|
timestamps.forEach((timestamp: number) => expect(timestamp).toBeGreaterThan(0));
|
|
373
372
|
});
|
|
@@ -378,8 +377,7 @@ describeFeature(feature, ({ Scenario }) => {
|
|
|
378
377
|
expect(responses[2].body.id).toBe("3");
|
|
379
378
|
});
|
|
380
379
|
|
|
381
|
-
And("
|
|
382
|
-
// All responses should be successful regardless of timing
|
|
380
|
+
And("all responses should complete with status 200", () => {
|
|
383
381
|
for (const response of responses) {
|
|
384
382
|
expect(response.status).toBe(200);
|
|
385
383
|
expect(response.body).toHaveProperty("id");
|
|
@@ -180,8 +180,7 @@ describeFeature(feature, ({ Scenario }) => {
|
|
|
180
180
|
}
|
|
181
181
|
});
|
|
182
182
|
|
|
183
|
-
And("
|
|
184
|
-
// If we got here without throwing, the mock handled the load
|
|
183
|
+
And("each response should confirm large payload processing", () => {
|
|
185
184
|
expect(responses.every(r => r.body.size === 'large')).toBe(true);
|
|
186
185
|
});
|
|
187
186
|
|
|
@@ -202,8 +201,7 @@ describeFeature(feature, ({ Scenario }) => {
|
|
|
202
201
|
}
|
|
203
202
|
});
|
|
204
203
|
|
|
205
|
-
And("
|
|
206
|
-
// Memory stability is tested by not crashing during multiple large requests
|
|
204
|
+
And("all accumulation requests should complete successfully", () => {
|
|
207
205
|
expect(responses).toHaveLength(5);
|
|
208
206
|
});
|
|
209
207
|
});
|
|
@@ -262,13 +260,12 @@ describeFeature(feature, ({ Scenario }) => {
|
|
|
262
260
|
expect(successCount + errorCount).toBe(responses.length);
|
|
263
261
|
});
|
|
264
262
|
|
|
265
|
-
And("the success rate should be
|
|
263
|
+
And("the success rate should be between {int}% and {int}%", (_, low: number, high: number) => {
|
|
266
264
|
const successCount = responses.filter(r => r.status === 200).length;
|
|
267
265
|
const actualRate = (successCount / responses.length) * 100;
|
|
268
266
|
|
|
269
|
-
|
|
270
|
-
expect(actualRate).
|
|
271
|
-
expect(actualRate).toBeLessThan(expectedRate + 10);
|
|
267
|
+
expect(actualRate).toBeGreaterThanOrEqual(low);
|
|
268
|
+
expect(actualRate).toBeLessThanOrEqual(high);
|
|
272
269
|
});
|
|
273
270
|
|
|
274
271
|
And("error responses should have appropriate status codes", () => {
|
|
@@ -298,7 +295,7 @@ describeFeature(feature, ({ Scenario }) => {
|
|
|
298
295
|
}
|
|
299
296
|
});
|
|
300
297
|
|
|
301
|
-
Then("each error should have a
|
|
298
|
+
Then("each error response should have a non-empty error message", () => {
|
|
302
299
|
for (const response of responses) {
|
|
303
300
|
expect(response.status).toBeGreaterThanOrEqual(400);
|
|
304
301
|
expect(response.body.error).toBeDefined();
|
|
@@ -307,7 +304,7 @@ describeFeature(feature, ({ Scenario }) => {
|
|
|
307
304
|
}
|
|
308
305
|
});
|
|
309
306
|
|
|
310
|
-
And("
|
|
307
|
+
And("each error response should have the correct status code", () => {
|
|
311
308
|
expect(responses[0].status).toBe(400); // No content-type
|
|
312
309
|
expect(responses[1].status).toBe(400); // No body
|
|
313
310
|
expect(responses[2].status).toBe(400); // Invalid body type
|
|
@@ -259,13 +259,14 @@ describeFeature(feature, ({ Scenario }) => {
|
|
|
259
259
|
requestResponses = [await mock.handle(method as any, path)];
|
|
260
260
|
});
|
|
261
261
|
|
|
262
|
-
Then("the response should have a {string} array", (_, property: string) => {
|
|
262
|
+
Then("the response should have a {string} array with {int} items", (_, property: string, count: number) => {
|
|
263
263
|
expect(requestResponses[0].body).toHaveProperty(property);
|
|
264
264
|
expect(Array.isArray(requestResponses[0].body[property])).toBe(true);
|
|
265
|
+
expect(requestResponses[0].body[property]).toHaveLength(count);
|
|
265
266
|
});
|
|
266
267
|
|
|
267
|
-
And("the response should have
|
|
268
|
-
expect(requestResponses[0].body).
|
|
268
|
+
And("the response should have {string} equal to {int}", (_, property: string, value: number) => {
|
|
269
|
+
expect(requestResponses[0].body[property]).toBe(value);
|
|
269
270
|
});
|
|
270
271
|
|
|
271
272
|
And(
|
|
@@ -58,8 +58,8 @@ describeFeature(feature, ({ Scenario }) => {
|
|
|
58
58
|
elapsed = performance.now() - start;
|
|
59
59
|
});
|
|
60
60
|
|
|
61
|
-
Then("the response took at least
|
|
62
|
-
expect(elapsed).toBeGreaterThanOrEqual(8);
|
|
61
|
+
Then("the response took at least 8ms", () => {
|
|
62
|
+
expect(elapsed).toBeGreaterThanOrEqual(8);
|
|
63
63
|
});
|
|
64
64
|
});
|
|
65
65
|
|
|
@@ -533,18 +533,18 @@ describeFeature(feature, ({ Scenario }) => {
|
|
|
533
533
|
responses = await Promise.all(promises);
|
|
534
534
|
});
|
|
535
535
|
|
|
536
|
-
Then("
|
|
536
|
+
Then("no response should report a cache size above 5", () => {
|
|
537
537
|
responses.forEach(response => {
|
|
538
538
|
expect((response.body as CacheResponseBody).cacheSize).toBeLessThanOrEqual(5);
|
|
539
539
|
});
|
|
540
540
|
});
|
|
541
541
|
|
|
542
|
-
And("
|
|
542
|
+
And("the final cache size should be 5", () => {
|
|
543
543
|
const finalCacheSize = Math.max(...responses.map(r => (r.body as CacheResponseBody).cacheSize));
|
|
544
544
|
expect(finalCacheSize).toBe(5);
|
|
545
545
|
});
|
|
546
546
|
|
|
547
|
-
And("
|
|
547
|
+
And("each response should confirm the item was cached", () => {
|
|
548
548
|
responses.forEach(response => {
|
|
549
549
|
const body = response.body as CacheResponseBody;
|
|
550
550
|
expect(body.cached).toBe(true);
|
|
@@ -617,7 +617,7 @@ describeFeature(feature, ({ Scenario }) => {
|
|
|
617
617
|
expect(activityUpdates).toHaveLength(3);
|
|
618
618
|
});
|
|
619
619
|
|
|
620
|
-
And("
|
|
620
|
+
And("user 1 should have 4 updates and user 2 should have 2", () => {
|
|
621
621
|
const user1Updates = responses.filter(r => (r.body as ProfileResponseBody).userId === "1");
|
|
622
622
|
const user2Updates = responses.filter(r => (r.body as ProfileResponseBody).userId === "2");
|
|
623
623
|
|
|
@@ -625,13 +625,7 @@ describeFeature(feature, ({ Scenario }) => {
|
|
|
625
625
|
expect(user2Updates).toHaveLength(2); // profile, activity
|
|
626
626
|
});
|
|
627
627
|
|
|
628
|
-
And("
|
|
629
|
-
responses.forEach(response => {
|
|
630
|
-
const body = response.body as ProfileResponseBody;
|
|
631
|
-
expect(body.userId).toBeDefined();
|
|
632
|
-
expect(["1", "2"]).toContain(body.userId);
|
|
633
|
-
});
|
|
634
|
-
|
|
628
|
+
And("user 1 activity count should be 2", () => {
|
|
635
629
|
const activityUpdates = responses.filter(r => (r.body as ProfileResponseBody).activityCount);
|
|
636
630
|
const user1Activities = activityUpdates.filter(r => (r.body as ProfileResponseBody).userId === "1");
|
|
637
631
|
expect(user1Activities.length).toBe(2);
|
|
@@ -733,7 +727,7 @@ describeFeature(feature, ({ Scenario }) => {
|
|
|
733
727
|
}
|
|
734
728
|
});
|
|
735
729
|
|
|
736
|
-
And("transaction
|
|
730
|
+
And("the transaction count should match the number of successful transactions", () => {
|
|
737
731
|
const successfulTransactions = responses.filter(r => (r.body as TransactionResponseBody).success === true);
|
|
738
732
|
if (successfulTransactions.length > 0) {
|
|
739
733
|
const transactionCounts = successfulTransactions.map(r => (r.body as TransactionResponseBody).transactionCount);
|