@schmock/core 2.2.2 → 2.3.0

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.
Files changed (45) hide show
  1. package/dist/binary.d.ts +8 -0
  2. package/dist/binary.d.ts.map +1 -0
  3. package/dist/binary.js +9 -0
  4. package/dist/builder.d.ts.map +1 -1
  5. package/dist/builder.js +60 -29
  6. package/dist/http-helpers.d.ts +15 -3
  7. package/dist/http-helpers.d.ts.map +1 -1
  8. package/dist/http-helpers.js +24 -6
  9. package/dist/index.d.ts +90 -27
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +1 -0
  12. package/dist/interceptor.d.ts.map +1 -1
  13. package/dist/interceptor.js +71 -20
  14. package/dist/plugin-pipeline.d.ts +11 -4
  15. package/dist/plugin-pipeline.d.ts.map +1 -1
  16. package/dist/plugin-pipeline.js +98 -35
  17. package/dist/response-parser.d.ts.map +1 -1
  18. package/dist/response-parser.js +47 -17
  19. package/package.json +5 -3
  20. package/src/binary.test.ts +126 -0
  21. package/src/binary.ts +11 -0
  22. package/src/builder.ts +82 -35
  23. package/src/http-helpers.test.ts +39 -0
  24. package/src/http-helpers.ts +46 -10
  25. package/src/index.ts +1 -0
  26. package/src/interceptor.test.ts +197 -0
  27. package/src/interceptor.ts +215 -128
  28. package/src/parser.property.test.ts +91 -55
  29. package/src/plugin-pipeline.ts +150 -45
  30. package/src/plugin-system.test.ts +95 -0
  31. package/src/response-parser.ts +58 -19
  32. package/src/server.test.ts +81 -12
  33. package/src/steps/async-support.steps.ts +29 -8
  34. package/src/steps/audit-onerror-tuple.steps.ts +14 -30
  35. package/src/steps/error-handling.steps.ts +463 -253
  36. package/src/steps/fetch-interceptor.steps.ts +457 -0
  37. package/src/steps/http-methods.steps.ts +19 -8
  38. package/src/steps/lifecycle-events.steps.ts +50 -43
  39. package/src/steps/performance-reliability.steps.ts +78 -411
  40. package/src/steps/plugin-integration.steps.ts +54 -0
  41. package/src/steps/request-history.steps.ts +412 -230
  42. package/src/steps/standalone-server.steps.ts +7 -13
  43. package/src/steps/state-concurrency.steps.ts +142 -714
  44. package/src/steps/interceptor.steps.ts +0 -260
  45. package/src/steps/stateful-workflows.steps.ts +0 -353
@@ -4,11 +4,15 @@ import { schmock } from "../index";
4
4
 
5
5
  const feature = await loadFeature("../../features/standalone-server.feature");
6
6
 
7
- describeFeature(feature, ({ Scenario }) => {
7
+ describeFeature(feature, ({ Scenario, AfterEachScenario }) => {
8
8
  let mock: Schmock.CallableMockInstance;
9
9
  let serverInfo: Schmock.ServerInfo;
10
10
  let httpResponse: Response;
11
11
 
12
+ AfterEachScenario(() => {
13
+ mock?.close();
14
+ });
15
+
12
16
  function baseUrl(): string {
13
17
  return `http://${serverInfo.hostname}:${serverInfo.port}`;
14
18
  }
@@ -49,12 +53,7 @@ describeFeature(feature, ({ Scenario }) => {
49
53
  });
50
54
 
51
55
  Then("the server should not be running", async () => {
52
- try {
53
- await fetch(`${baseUrl()}/hello`);
54
- expect.unreachable("Should not be able to connect");
55
- } catch {
56
- // Connection refused — server is down
57
- }
56
+ await expect(fetch(`${baseUrl()}/hello`)).rejects.toBeDefined();
58
57
  });
59
58
  });
60
59
 
@@ -222,12 +221,7 @@ describeFeature(feature, ({ Scenario }) => {
222
221
  });
223
222
 
224
223
  Then("the server should not be running", async () => {
225
- try {
226
- await fetch(`${baseUrl()}/hello`);
227
- expect.unreachable("Should not be able to connect");
228
- } catch {
229
- // Connection refused — server is down
230
- }
224
+ await expect(fetch(`${baseUrl()}/hello`)).rejects.toBeDefined();
231
225
  });
232
226
  });
233
227
  });