@testing-library/react#getByAltText JavaScript Examples

The following examples show how to use @testing-library/react#getByAltText. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: registrationLogin.js    From shopping-cart-fe with MIT License 5 votes vote down vote up
// These tests ensure all elements are rendering on login

describe('login screen and registration screens', () => {
  test('renders the title on login', () => {
    const { getByText } = renderWithProviders(<Login />);
    const title = getByText(/LogIn to your Store/i);
    expect(title).toBeVisible();
  });
  test('renders logo', () => {
    const { getByTestId } = renderWithProviders(<Login />);
    expect(getByTestId('loginLogo')).toBeVisible();
  });
  test('renders phone number input', () => {
    const { getByTestId } = renderWithProviders(<Login />);
    expect(getByTestId('phoneNumberInput')).toBeVisible();
  });
  test('renders password input', () => {
    const { getByTestId } = renderWithProviders(<Login />);
    expect(getByTestId('loginPasswordInput')).toBeVisible();
  });
  test('renders forgot password link', () => {
    const { getByText } = renderWithProviders(<Login />);
    expect(getByText(/forgot password/i)).toBeVisible();
  });
  test('renders login button', () => {
    const { getByTestId } = renderWithProviders(<Login />);
    expect(getByTestId('loginButton')).toBeVisible();
  });
  test('renders create store button', () => {
    const { getByTestId } = renderWithProviders(<Login />);
    expect(getByTestId('createStoreButton')).toBeVisible();
  });
  test('renders main login image', () => {
    const { getByAltText } = renderWithProviders(<Login />);
    expect(getByAltText(/login/i)).toBeVisible();
  });
  test('renders colorful image background', () => {
    const { getByTestId } = renderWithProviders(<Login />);
    expect(getByTestId('imageBackground')).toBeVisible();
  });
  test('renders phone / password background div', () => {
    const { getByTestId } = renderWithProviders(<Login />);
    expect(getByTestId('loginFormWrapper')).toBeVisible();
  });
  
});