Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

jest testing with ResizeObserver

import React from 'react';

import { render, fireEvent } from '@testing-library/react';

import { AuthProvider } from '../context/AuthProvider';
import LoginPage from './LoginPage';

const pass = 'pass';
const user = 'user';
class ResizeObserver {
  observe() {}
  unobserve() {}
}
describe('loginpage ', () => {
  window.ResizeObserver = ResizeObserver;
  test('should update username and password', async () => {
    const { findByPlaceholderText } = render(
      <AuthProvider>
        <LoginPage />
      </AuthProvider>,
    );
    const username = await findByPlaceholderText('Your username...');
    const password = await findByPlaceholderText('Password...');
    fireEvent.change(username, { target: { value: user } });
    fireEvent.change(password, { target: { value: pass } });
    expect(username.value).toBe(user);
    expect(password.value).toBe(pass);
  });
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: angular chart js 
Javascript :: javascript ide 
Javascript :: added font to react native 
Javascript :: js array elements sum 
Javascript :: nodejs heap usage 
Javascript :: react hook form reset only one field 
Javascript :: returned value by findOneAndUpdate 
Javascript :: get main tr from td jquery 
Javascript :: what is an async function 
Javascript :: how to copy all the elements of an array except the last one in javascript 
Javascript :: template literals javascript 
Javascript :: playwright headless 
Javascript :: this.props undefined react native 
Javascript :: json.stringify 
Javascript :: Convert array to string while preserving brackets 
Javascript :: javascript palindrome 
Javascript :: children array javascript 
Javascript :: antd react 
Javascript :: reddit fetch api js 
Javascript :: merg two array js 
Javascript :: how to use iframe for youtube video in react 
Javascript :: javascript spread array without duplicates 
Javascript :: createelement add class 
Javascript :: null value check in react js 
Javascript :: How do i write a script which generates a random rgb color number. 
Javascript :: extract the last number of two digits number js 
Javascript :: comment in js 
Javascript :: Using axios send a GET request to the address: 
Javascript :: angular decorators list 
Javascript :: npm react-device-detect 
ADD CONTENT
Topic
Content
Source link
Name
5+3 =