How to use the @testing-library/dom.screen.findByTestId function in @testing-library/dom

To help you get started, we’ve selected a few @testing-library/dom examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gitlabhq / gitlabhq / spec / frontend_integration / ide / user_opens_ide_spec.js View on Github external
it('shows image viewer', async () => {
      const viewer = await screen.findByTestId('image-viewer');
      const img = viewer.querySelector('img');

      expect(img.src).toContain('logo-white.png');
    });
  });
github gitlabhq / gitlabhq / spec / frontend_integration / ide / user_opens_ide_spec.js View on Github external
it('shows branch/MR dropdown with master selected', async () => {
      const dropdown = await screen.findByTestId('ide-nav-dropdown');

      expect(dropdown.textContent).toContain('master');
    });
  });
github gitlabhq / gitlabhq / spec / frontend_integration / ide / user_opens_ide_spec.js View on Github external
it('shows commit button in disabled state', async () => {
      const button = await screen.findByTestId('begin-commit-button');

      expect(button.getAttribute('disabled')).toBeDefined();
    });
github gitlabhq / gitlabhq / spec / frontend_integration / ide / helpers / ide_helper.js View on Github external
const fillFileNameModal = async (value, submitText = 'Create file') => {
  const modal = await screen.findByTestId('ide-new-entry');

  const nameField = await findByTestId(modal, 'file-name-field');
  fireEvent.input(nameField, { target: { value } });

  const createButton = getByText(modal, submitText, { selector: 'button' });
  createButton.click();
};
github gitlabhq / gitlabhq / spec / frontend_integration / ide / helpers / ide_helper.js View on Github external
export const commit = async ({ newBranch = false, newMR = false, newBranchName = '' } = {}) => {
  switchLeftSidebarTab('Commit');
  screen.getByTestId('begin-commit-button').click();

  if (!newBranch) {
    const option = await screen.findByLabelText(/Commit to .+ branch/);
    option.click();
  } else {
    const option = await screen.findByLabelText('Create a new branch');
    option.click();

    const branchNameInput = await screen.findByTestId('ide-new-branch-name');
    fireEvent.input(branchNameInput, { target: { value: newBranchName } });

    const mrCheck = await screen.findByLabelText('Start a new merge request');
    if (Boolean(mrCheck.checked) !== newMR) {
      mrCheck.click();
    }
  }

  screen.getByText('Commit').click();
};
github gitlabhq / gitlabhq / spec / frontend_integration / ide / helpers / ide_helper.js View on Github external
const findRootActions = () => screen.findByTestId('ide-root-actions');