Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

To have attribute improvement + improved test coverage #454

Merged
merged 16 commits into from
Jun 7, 2021

Conversation

Harry-Liversedge
Copy link
Contributor

  • Adds a parameter check to distinguish between toHaveAttribute('attrib') toHaveAttribute('attrib', 'value')
  • Adds test cases for toHaveAttribute
  • Updates all matchers that make use of toHaveAttribute
  • Adds test cases for all matchers that make use of toHaveAttribute

In support of #2 improving unit test coverage
closes #438

@Harry-Liversedge Harry-Liversedge changed the title Tests to have attrib To have attribute improvement + improved test coverage Jun 1, 2021
@mgrybyk
Copy link
Member

mgrybyk commented Jun 1, 2021

I'd only add tests and avoid refactoring of matchers.

@Harry-Liversedge
Copy link
Contributor Author

Harry-Liversedge commented Jun 1, 2021

That is what I initially was doing I do agree, but in #438 I had noticed that there was an unexpected behaviour whereby if you pass in a non-string it previously would always succeed i.e this test would fail:

test('failure with non-string attribute value as expected', async () => {
   el.getAttribute = jest.fn().mockImplementation((attribute: string) => {
      return "Correct Value"
   })
   const result = await toHaveAttribute(el, "attribute_name", 123, { ignoreCase: true });
   expect(result.pass).toBe(false)
})

Copy link
Member

@christian-bromann christian-bromann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me 👍

@mgrybyk good to merge from your side too?

@christian-bromann christian-bromann merged commit 8d1e408 into webdriverio:main Jun 7, 2021
@christian-bromann
Copy link
Member

@Harry-Liversedge thanks so much for this contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

toHaveAttribute type checking
3 participants