Generate Fern TypeSscript SDK (#3785)
This commit is contained in:
committed by
GitHub
parent
d55b9637c4
commit
2062adac66
29
skyvern-ts/client/tests/mock-server/MockServer.ts
Normal file
29
skyvern-ts/client/tests/mock-server/MockServer.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import type { RequestHandlerOptions } from "msw";
|
||||
import type { SetupServer } from "msw/node";
|
||||
|
||||
import { mockEndpointBuilder } from "./mockEndpointBuilder";
|
||||
|
||||
export interface MockServerOptions {
|
||||
baseUrl: string;
|
||||
server: SetupServer;
|
||||
}
|
||||
|
||||
export class MockServer {
|
||||
private readonly server: SetupServer;
|
||||
public readonly baseUrl: string;
|
||||
|
||||
constructor({ baseUrl, server }: MockServerOptions) {
|
||||
this.baseUrl = baseUrl.endsWith("/") ? baseUrl.slice(0, -1) : baseUrl;
|
||||
this.server = server;
|
||||
}
|
||||
|
||||
public mockEndpoint(options?: RequestHandlerOptions): ReturnType<typeof mockEndpointBuilder> {
|
||||
const builder = mockEndpointBuilder({
|
||||
once: options?.once,
|
||||
onBuild: (handler) => {
|
||||
this.server.use(handler);
|
||||
},
|
||||
}).baseUrl(this.baseUrl);
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user