@frontmcp/testing 1.7.2 → 1.8.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.
- package/client/index.d.ts +1 -1
- package/client/index.d.ts.map +1 -1
- package/client/mcp-test-client.builder.d.ts +2 -1
- package/client/mcp-test-client.builder.d.ts.map +1 -1
- package/client/mcp-test-client.d.ts +11 -3
- package/client/mcp-test-client.d.ts.map +1 -1
- package/client/mcp-test-client.types.d.ts +17 -3
- package/client/mcp-test-client.types.d.ts.map +1 -1
- package/esm/fixtures/index.mjs +670 -458
- package/esm/index.mjs +780 -569
- package/esm/matchers/index.mjs +5 -6
- package/esm/package.json +6 -6
- package/esm/perf/index.mjs +600 -426
- package/esm/setup.mjs +5 -6
- package/fixtures/fixture-types.d.ts +34 -3
- package/fixtures/fixture-types.d.ts.map +1 -1
- package/fixtures/index.js +670 -458
- package/fixtures/test-fixture.d.ts.map +1 -1
- package/index.d.ts +1 -1
- package/index.d.ts.map +1 -1
- package/index.js +780 -569
- package/matchers/index.js +5 -6
- package/matchers/matcher-types.d.ts +3 -2
- package/matchers/matcher-types.d.ts.map +1 -1
- package/matchers/mcp-matchers.d.ts +1 -1
- package/matchers/mcp-matchers.d.ts.map +1 -1
- package/package.json +6 -6
- package/perf/index.js +600 -426
- package/setup.js +5 -6
- package/transport/index.d.ts +1 -1
- package/transport/index.d.ts.map +1 -1
- package/transport/streamable-http.transport.d.ts +18 -2
- package/transport/streamable-http.transport.d.ts.map +1 -1
- package/transport/transport.interface.d.ts +17 -1
- package/transport/transport.interface.d.ts.map +1 -1
package/esm/setup.mjs
CHANGED
|
@@ -397,18 +397,17 @@ var init_mcp_matchers = __esm({
|
|
|
397
397
|
message: () => `Expected a result wrapper object with isError property`
|
|
398
398
|
};
|
|
399
399
|
}
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
}
|
|
400
|
+
const receivedCode = typeof expectedCode === "string" ? result.raw?._meta?.["code"] : result.error?.code;
|
|
401
|
+
const codeMatches = expectedCode === void 0 || receivedCode === expectedCode;
|
|
402
|
+
const pass = result.isError && codeMatches;
|
|
404
403
|
return {
|
|
405
404
|
pass,
|
|
406
405
|
message: () => {
|
|
407
406
|
if (!result.isError) {
|
|
408
407
|
return "Expected result to be an error, but it was successful";
|
|
409
408
|
}
|
|
410
|
-
if (
|
|
411
|
-
return `Expected error code ${expectedCode}, but got ${
|
|
409
|
+
if (!codeMatches) {
|
|
410
|
+
return `Expected error code ${expectedCode}, but got ${String(receivedCode)}`;
|
|
412
411
|
}
|
|
413
412
|
return "Expected result not to be an error";
|
|
414
413
|
}
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* @file fixture-types.ts
|
|
3
3
|
* @description Type definitions for test fixtures
|
|
4
4
|
*/
|
|
5
|
+
import type { JWK } from 'jose';
|
|
5
6
|
import type { McpTestClient } from '../client/mcp-test-client';
|
|
6
7
|
import type { McpTestClientBuilder } from '../client/mcp-test-client.builder';
|
|
7
|
-
import type { JWK } from 'jose';
|
|
8
8
|
/**
|
|
9
9
|
* Configuration passed to test.use()
|
|
10
10
|
*/
|
|
@@ -41,8 +41,25 @@ export interface TestConfig {
|
|
|
41
41
|
env?: Record<string, string>;
|
|
42
42
|
/** Startup timeout in ms (default: 30000) */
|
|
43
43
|
startupTimeout?: number;
|
|
44
|
-
/**
|
|
44
|
+
/**
|
|
45
|
+
* Base URL for connecting to an external/already running server.
|
|
46
|
+
*
|
|
47
|
+
* May also be supplied alongside `server`, in which case the booted server's
|
|
48
|
+
* own URL is overridden — useful when the server is reachable through a proxy
|
|
49
|
+
* or a different host than it binds (issue #543).
|
|
50
|
+
*/
|
|
45
51
|
baseUrl?: string;
|
|
52
|
+
/**
|
|
53
|
+
* The server's `http.entryPath` — where MCP is mounted (`'/mcp'`, …).
|
|
54
|
+
* Defaults to the server root.
|
|
55
|
+
*
|
|
56
|
+
* Issue #543: setting `http.entryPath` on the server used to take the whole
|
|
57
|
+
* suite down, because the fixture always pointed its client at the root and
|
|
58
|
+
* every spec failed with an opaque `HTTP 404` from inside the test client.
|
|
59
|
+
* The client also recovers on its own when the server reports its paths in a
|
|
60
|
+
* 404 body, so this is only needed when that report is unavailable.
|
|
61
|
+
*/
|
|
62
|
+
entryPath?: string;
|
|
46
63
|
}
|
|
47
64
|
/**
|
|
48
65
|
* Fixtures available in test functions
|
|
@@ -136,6 +153,8 @@ export interface ServerFixture {
|
|
|
136
153
|
name: string;
|
|
137
154
|
version: string;
|
|
138
155
|
};
|
|
156
|
+
/** Override the MCP entry path for this client (default: `test.use()`'s). */
|
|
157
|
+
entryPath?: string;
|
|
139
158
|
}): Promise<McpTestClient>;
|
|
140
159
|
/**
|
|
141
160
|
* Create a client builder for full customization.
|
|
@@ -185,8 +204,20 @@ export interface TestWithFixtures {
|
|
|
185
204
|
afterEach: typeof afterEach;
|
|
186
205
|
/** Run after all tests in the file */
|
|
187
206
|
afterAll: typeof afterAll;
|
|
188
|
-
/** Skip a test */
|
|
207
|
+
/** Skip a named test. */
|
|
189
208
|
skip(name: string, fn: TestFn): void;
|
|
209
|
+
/**
|
|
210
|
+
* Playwright-style conditional skip: when `condition` is true, every test
|
|
211
|
+
* registered after this call in the enclosing `describe` (or file) is
|
|
212
|
+
* skipped. Put it at the top of the block you want to gate.
|
|
213
|
+
*
|
|
214
|
+
* @example
|
|
215
|
+
* test.describe('against the live API', () => {
|
|
216
|
+
* test.skip(!hasCredentials, 'credentials not set');
|
|
217
|
+
* test('lookup', async ({ mcp }) => { ... });
|
|
218
|
+
* });
|
|
219
|
+
*/
|
|
220
|
+
skip(condition: boolean, reason?: string): void;
|
|
190
221
|
/** Run only this test */
|
|
191
222
|
only(name: string, fn: TestFn): void;
|
|
192
223
|
/** Mark test as todo (not implemented) */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fixture-types.d.ts","sourceRoot":"","sources":["../../src/fixtures/fixture-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,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