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
Just importing some livekit components should not break my test setup.
How to resolve
In places like this where you're using TextEncoder or TextDecoder, do not instantiate the encoder at the top level of the file. Wait until the function is called that needs the encoder, and initialize it then.
Reproduction
Add the following import to a jest spec and run it:
import {
type AgentState,
LiveKitRoom,
useVoiceAssistant,
BarVisualizer,
RoomAudioRenderer,
VoiceAssistantControlBar,
DisconnectButton,
} from '@livekit/components-react';
I get your point, but I think this is an issue of the jest environment not defining TextEncoder which is a globally available constructor on all supported browers.
Select which package(s) are affected
@livekit/components-core
Describe the bug
What is happening
I have a jest spec that imports a LiveKit component that has this code:
I'm not actually using that LiveKit component in this spec at all. It just happens to be getting imported.
The test run fails on
ReferenceError: TextEncoder is not defined
I can fix this by adding this to my setup:
What I expect
Just importing some livekit components should not break my test setup.
How to resolve
In places like this where you're using TextEncoder or TextDecoder, do not instantiate the encoder at the top level of the file. Wait until the function is called that needs the encoder, and initialize it then.
Reproduction
Add the following import to a jest spec and run it:
Logs
No response
System Info
Severity
annoyance
Additional Information
No response
The text was updated successfully, but these errors were encountered: