Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async fetch(url: string, init?: RequestInit): Promise {
const seed = FixtureStorage.createByUrl>(
url,
init,
this.testScope
)
try {
const seedFixture = seed.get()
if (!seed.expired) {
// seed exists => return seed
return createResponse(seedFixture)
}
} catch {
// ignore
}
const fixture = await this.fetchFixture(url, init)
seed.set(fixture)
const seedify = async (fnc: ClientFunction, name: string, args: any) => {
const seed = FxSt.createByUrl(
`${endpoint}/${name}`,
args,
this.testScope
)
try {
try {
if (seed.expired) {
throw new Error()
}
const response = seed.get()
handleSeedError(response)
return response
} catch {
const response = await fnc(args)
seed.set(response)
return response
const purify = async (fnc: ClientFunction, name: string, args: any) => {
const seed = FixtureStorage.createByUrl(
`${endpoint}/${name}`,
args,
this.testScope
)
const response = seed.get()
handleSeedError(response)
return response
}