You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been trying to integrate uvu and react-testing-library into my team's tech stack. FYI, I can't use Jest because of the infamous Unexpected token 'export' in one of my dependencies.
The challenge I'm facing right now is to mock Firebase functions that is called in my custom hooks. Something like this:
// Custom hookimport{signInAnonymously,onAuthStateChanged}from"firebase/auth";import{useEffect,useState}from"react";import{auth}from"@/connections/firebase";exportfunctionuseAuthentication(){const[isReady,setReady]=useState(false);useEffect(()=>{constunsubscribe=onAuthStateChanged(auth,(user)=>{if(user){setReady(true);}else{signInAnonymously(auth).then(()=>{console.log("Signed in anonymously");}).catch((error)=>{console.error(error.message);});}});returnunsubscribe;},[]);returnisReady;}
// The componentimport{useAuthentication}from"@/hooks/auth";importtype{FC,ReactNode}from"react";interfaceLayoutProps{children: ReactNode;}constLayout: FC<LayoutProps>=({ children })=>{constisReady=useAuthentication();if(!isReady){returnnull;}returnchildren;};exportdefaultLayout;
I really need to mock useAuthentication and have it returns true so RTL can properly test the component. I've been trying to use sinon but still no luck. I'm sorry if this is not place to ask questions about usage. I'm getting desperate because of the lack of blog and articles about uvu out there. uvu's support for native ES modules—unlike Jest—is one of the factors that make me plan to stick with it in the future :)
Thank you.
The text was updated successfully, but these errors were encountered:
Hi folks
I've been trying to integrate
uvu
andreact-testing-library
into my team's tech stack. FYI, I can't use Jest because of the infamousUnexpected token 'export'
in one of my dependencies.The challenge I'm facing right now is to mock Firebase functions that is called in my custom hooks. Something like this:
I really need to mock
useAuthentication
and have it returnstrue
so RTL can properly test the component. I've been trying to usesinon
but still no luck. I'm sorry if this is not place to ask questions about usage. I'm getting desperate because of the lack of blog and articles aboutuvu
out there.uvu
's support for native ES modules—unlike Jest—is one of the factors that make me plan to stick with it in the future :)Thank you.
The text was updated successfully, but these errors were encountered: