@testspectra/skills 1.3.1 → 1.3.2

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.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: network-interception
3
- description: The Spectra.intercept() API for deterministic network mocking in TestSpectra — InterceptRule/MockResponse/MockHandle shapes, respondOnce vs respondWith sequential polling, aborting requests, and waitForCall/callCount assertions. Use whenever a test needs to mock, stub, or assert on an API call instead of hitting the real backend.
3
+ description: The Spectra.intercept() API for deterministic network mocking in TestSpectra — InterceptRule/MockResponse/MockHandle shapes, respondOnce vs respondWith sequential polling, aborting requests, and waitForCall/shouldHaveCallCount assertions. Use whenever a test needs to mock, stub, or assert on an API call instead of hitting the real backend.
4
4
  ---
5
5
 
6
6
  # Skill: Network Interception (`Spectra.intercept`)
@@ -31,6 +31,7 @@ interface MockHandle {
31
31
  respondOnce(response: MockResponse): this; // one-time FIFO-queued response
32
32
  abort(errorCode?: 'Failed' | 'Aborted' | 'TimedOut' | 'ConnectionReset'): this;
33
33
  waitForCall(options?: { timeout?: number; count?: number }): Promise<InterceptedRequest>;
34
+ shouldHaveCallCount(count: number, options?: { timeout?: number }): Promise<void>; // polls; 0 proves no request went out
34
35
  readonly callCount: number;
35
36
  readonly calls: InterceptedRequest[];
36
37
  }
@@ -58,7 +59,7 @@ it('should mock payment failure response gracefully', async () => {
58
59
  await CheckoutPage.submitPaymentButton.click();
59
60
 
60
61
  await paymentMock.waitForCall({ timeout: 5000 });
61
- expect(paymentMock.callCount).toBe(1);
62
+ await paymentMock.shouldHaveCallCount(1);
62
63
 
63
64
  await CheckoutPage.errorBanner.shouldBeVisible();
64
65
  await CheckoutPage.errorBanner.shouldContainText('insufficient funds');
@@ -109,8 +110,9 @@ it('should handle offline mode gracefully when sync fails', async () => {
109
110
  - Only mock what the test is actually about — don't blanket-intercept every domain; the linter and
110
111
  reviewers expect `monitoredDomains` in `spectra.config.ts` (see the `workspace-structure` skill)
111
112
  to reflect real traffic, and over-mocking hides real integration regressions.
112
- - Always assert on the mock (`waitForCall` / `callCount`) when the test's purpose is to verify the
113
- request was made — don't just assert on UI state and silently hope the mock fired.
113
+ - Always assert on the mock (`waitForCall` / `shouldHaveCallCount(n)`) when the test's purpose is to
114
+ verify the request was made — don't just assert on UI state and silently hope the mock fired. A
115
+ blocked submit: `shouldHaveCallCount(0)` after the `should*` on the state the app settles in.
114
116
  - Every real (non-mocked) network call made during a run is separately captured and written to
115
117
  `.testspectra/reports/network-resources.json` for post-run diagnostics — you don't need to record
116
118
  this yourself.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testspectra/skills",
3
- "version": "1.3.1",
3
+ "version": "1.3.2",
4
4
  "description": "Installer & manager for modular AI agent skills that standardize TestSpectra script authoring (specs, page objects, steps, actions, hooks, fixtures, matchers)",
5
5
  "keywords": [
6
6
  "agents",
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: network-interception
3
- description: The Spectra.intercept() API for deterministic network mocking in TestSpectra — InterceptRule/MockResponse/MockHandle shapes, respondOnce vs respondWith sequential polling, aborting requests, and waitForCall/callCount assertions. Use whenever a test needs to mock, stub, or assert on an API call instead of hitting the real backend.
3
+ description: The Spectra.intercept() API for deterministic network mocking in TestSpectra — InterceptRule/MockResponse/MockHandle shapes, respondOnce vs respondWith sequential polling, aborting requests, and waitForCall/shouldHaveCallCount assertions. Use whenever a test needs to mock, stub, or assert on an API call instead of hitting the real backend.
4
4
  ---
5
5
 
6
6
  # Skill: Network Interception (`Spectra.intercept`)
@@ -31,6 +31,7 @@ interface MockHandle {
31
31
  respondOnce(response: MockResponse): this; // one-time FIFO-queued response
32
32
  abort(errorCode?: 'Failed' | 'Aborted' | 'TimedOut' | 'ConnectionReset'): this;
33
33
  waitForCall(options?: { timeout?: number; count?: number }): Promise<InterceptedRequest>;
34
+ shouldHaveCallCount(count: number, options?: { timeout?: number }): Promise<void>; // polls; 0 proves no request went out
34
35
  readonly callCount: number;
35
36
  readonly calls: InterceptedRequest[];
36
37
  }
@@ -58,7 +59,7 @@ it('should mock payment failure response gracefully', async () => {
58
59
  await CheckoutPage.submitPaymentButton.click();
59
60
 
60
61
  await paymentMock.waitForCall({ timeout: 5000 });
61
- expect(paymentMock.callCount).toBe(1);
62
+ await paymentMock.shouldHaveCallCount(1);
62
63
 
63
64
  await CheckoutPage.errorBanner.shouldBeVisible();
64
65
  await CheckoutPage.errorBanner.shouldContainText('insufficient funds');
@@ -109,8 +110,9 @@ it('should handle offline mode gracefully when sync fails', async () => {
109
110
  - Only mock what the test is actually about — don't blanket-intercept every domain; the linter and
110
111
  reviewers expect `monitoredDomains` in `spectra.config.ts` (see the `workspace-structure` skill)
111
112
  to reflect real traffic, and over-mocking hides real integration regressions.
112
- - Always assert on the mock (`waitForCall` / `callCount`) when the test's purpose is to verify the
113
- request was made — don't just assert on UI state and silently hope the mock fired.
113
+ - Always assert on the mock (`waitForCall` / `shouldHaveCallCount(n)`) when the test's purpose is to
114
+ verify the request was made — don't just assert on UI state and silently hope the mock fired. A
115
+ blocked submit: `shouldHaveCallCount(0)` after the `should*` on the state the app settles in.
114
116
  - Every real (non-mocked) network call made during a run is separately captured and written to
115
117
  `.testspectra/reports/network-resources.json` for post-run diagnostics — you don't need to record
116
118
  this yourself.