I have created a project that is using firebase for authentication and real-time database and i have created a simple test case for the component that the top option of the select element should be 'us' and 'technology' but it is giving me "TEXTDECODER IS NOT DEFINED" in firebase configuration file from where i am using all the database and authentication functions like getAuth() and ref() etc.
src/components/News.test.js
● Test suite failed to run
ReferenceError: TextDecoder is not defined
1 | import { initializeApp } from "firebase/app";
2 | import { getDatabase, ref, set, } from "firebase/database";
> 3 | import { getAuth } from "firebase/auth";
|
How to solve this ?
import React from 'react';
import { render,} from '@testing-library/react';
import '@testing-library/jest-dom/extend-expect';
import News from './News';
test('renders with default option "Technology"', async () => {
const { getByLabelText } = render(<News />);
const countrySelect = getByLabelText('Country:');
const categorySelect = getByLabelText('Category:');
expect(countrySelect).toHaveValue('us'); // Assuming 'us' is the default country
expect(categorySelect).toHaveValue('technology'); // Assuming 'technology' is the default category
});