Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | 1x 4x 4x 4x 4x 3x 4x 1x 1x 1x 2x 1x 1x 1x 1x 1x | import {delay, http, HttpResponse} from 'msw'
import pokemonsMock from './pokemons.mock.ts';
import versions from './versions.mock.ts';
export const handlers =
[ http.get('/pokemon', ({ request }) =>
{
const url = new URL(request.url);
const limit = url.searchParams.get('limit');
const data = structuredClone(pokemonsMock);
if( limit )
data.results = data.results.slice(0,Number(limit))
return HttpResponse.json(data); })
, http.get('/noreturn', async () =>
{
await delay(500);
// half second to be able to catch the initial state before the full data returned;
return HttpResponse.json(pokemonsMock);
})
, http.get('/reflect', ({request}) =>
{ const headers: Record<string, string> = {};
[...request.headers.entries()].map(([key, val]) => headers[key] = 'reflected-'+val);
headers['x-added'] = 'abc';
return HttpResponse.json(pokemonsMock, {headers});
})
, http.get('/404', () =>
{
return new HttpResponse(null, {status: 404, statusText: 'not found'})
})
,
];
// only for local
Eif( !window.location.pathname.startsWith('@epa-wg/custom-element-dist'))
handlers.push(http.get('https://registry.npmjs.org/@epa-wg/custom-element-dist', async () =>
{
return HttpResponse.json(versions);
})) |