Created
August 30, 2024 20:40
-
-
Save dadamssg/30de40d1b23a93428f1c14f3c5ad4717 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type MockArgs = { | |
path: string | |
method: 'get' | 'post' | 'put' | 'delete' | |
once?: boolean | |
response: any | |
} | |
export async function mock(args: MockArgs) { | |
const url = args.path.startsWith('http') ? args.path : `http://localhost:6000${args.path}` | |
return fetch('http://localhost:3000/app/playwright', { | |
method: 'POST', | |
headers: { 'content-type': 'application/json' }, | |
body: JSON.stringify({ | |
...args, | |
url, | |
}), | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment