Matchers

Last updated 6 months ago
  • toExist()

    • e.g. expect('.zippy__content').not.toExist();

  • toHaveLength()

    • e.g. expect('.zippy__content').toHaveLength(3);

  • toHaveId()

    • e.g. expect('.zippy__content').toHaveId('ID')

  • toHaveClass(class)

    • e.g. expect('.zippy__content').toHaveClass('class');

    • e.g. expect('.zippy__content').toHaveClass('class a, class b');

  • toHaveAttribute(attr, val)

    • e.g. expect(host.query('.zippy')).toHaveAttr({ attr: 'id', val: 'zippy' });

  • toHaveProperty(prop, val)

    • e.g. expect(host.query('.checkbox')).toHaveProp({ prop: 'checked', val: true });

  • toHaveText(text)

    • e.g. expect('.zippy__content').toHaveText('Content');

    • e.g. expect('.zippy__content').toHaveText((text) => text.includes('..')

  • toHaveValue(value)

    • e.g. expect('.zippy__content').toHaveValue('value');

  • toHaveStyle(value)

    • e.g. expect(host.element).toHaveStyle({backgroundColor: ‘rgba(0, 0, 0, 0.1)’});

  • toHaveData({data, val})

    • e.g. expect('.zippy__content').toHaveData({data: 'role', val: 'admin'});

  • toBeChecked()

    • e.g. expect('.checkbox').toBeDisabled();

  • toBeDisabled()

    • e.g. expect('.button').toBeDisabled();

  • toBeEmpty()

    • e.g. expect('div').toBeEmpty();

  • toBeEmpty()

    • e.g. expect('div').toBeEmpty();

  • toBeHidden()

    • e.g. expect('div').toBeHidden();

  • toBeSelected()

    • e.g. expect('element').toBeSelected();

  • toBeVisible()

    • e.g. expect('element').toBeVisible();

  • toBeFocused()

    • e.g. expect('input').toBeFocused();

  • toBeMatchedBy(selector)

    • e.g. expect('div').toBeMatchedBy('.js-something')

  • toHaveDescendant(selector)

    • e.g. expect('div').toHaveDescendant('.child')

  • toHaveDescendantWithText({selector, text})

    • e.g. expect('div').toHaveDescendantWithText({selector: '.child', text: 'text'})