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

First class support for test id's #286

Merged
merged 4 commits into from
Sep 21, 2019
Merged

Conversation

sunesimonsen
Copy link
Member

@sunesimonsen sunesimonsen commented Sep 20, 2019

It is becoming a recognised pattern for DOM testing to use test id's on elements.

Test id's is just a adding a data-test-id attribute to elements so you have a stable way of finding them from your tests.

We can already handle those, but it is kind of inconvenient and given how often it is used, I think we should add first class support for the concept.

Fixes: #285

@sunesimonsen sunesimonsen force-pushed the ssimonsen/query-test-id branch from 4741404 to 3f3b66b Compare September 20, 2019 21:14
@coveralls
Copy link

coveralls commented Sep 20, 2019

Pull Request Test Coverage Report for Build 1203

  • 16 of 16 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.1%) to 93.604%

Totals Coverage Status
Change from base Build 1195: 0.1%
Covered Lines: 673
Relevant Lines: 702

💛 - Coveralls

@sunesimonsen sunesimonsen force-pushed the ssimonsen/query-test-id branch from 3f3b66b to 4adf6ab Compare September 20, 2019 21:29
Copy link
Member

@alexjeffburke alexjeffburke left a comment

Choose a reason for hiding this comment

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

I’m all for this and doubly so for allowing not when doing the contain elements assertion.

Copy link
Member

@papandreou papandreou left a comment

Choose a reason for hiding this comment

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

Looks good! 🚀

(expect, subject, testId) => {
expect.errorMode = 'nested';
expect.subjectOutput = output =>
expect.inspect(subject, Infinity, output);
Copy link
Member

Choose a reason for hiding this comment

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

Is this to avoid dotting out? Is it something we want in some of the other assertions as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I have experience cases where we dot out stuff that contains conflicts. We should go through all of the assertions and make sure that we don't remove useful information, but that is a separate task: #287

@sunesimonsen sunesimonsen merged commit 462769d into master Sep 21, 2019
@sunesimonsen sunesimonsen deleted the ssimonsen/query-test-id branch September 21, 2019 06:10
@sunesimonsen
Copy link
Member Author

Released as [email protected]

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

Successfully merging this pull request may close these issues.

Allow querying for test ids
4 participants