Skip to content

Instantly share code, notes, and snippets.

@dadamssg
Created August 30, 2024 20:40
Show Gist options
  • Save dadamssg/30de40d1b23a93428f1c14f3c5ad4717 to your computer and use it in GitHub Desktop.
Save dadamssg/30de40d1b23a93428f1c14f3c5ad4717 to your computer and use it in GitHub Desktop.
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