UNPKG

@clerk/testing

Version:

Utilities to help you create E2E test suites for apps using Clerk

2 lines 838 B
import{a as p,b as i}from"./chunk-M5YIJ3SE.mjs";var h=async({context:c,options:l,page:T})=>{let o=c??T?.context();if(!o)throw new Error("Either context or page must be provided to setup testing token");let r=l?.frontendApiUrl||process.env.CLERK_FAPI;if(!r)throw new Error(i);let g=r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),f=new RegExp(`^https://${g}/v1/.*?(\\?.*)?$`);await o.route(f,async e=>{let s=new URL(e.request().url()),n=process.env.CLERK_TESTING_TOKEN;n&&s.searchParams.set(p,n);try{let a=await e.fetch({url:s.toString()}),t=await a.json();t?.response?.captcha_bypass===!1&&(t.response.captcha_bypass=!0),t?.client?.captcha_bypass===!1&&(t.client.captcha_bypass=!0),await e.fulfill({response:a,json:t})}catch{await e.continue({url:s.toString()}).catch(console.error)}})};export{h as a}; //# sourceMappingURL=chunk-YFUXUEZ5.mjs.map