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

Update guides to show using matchers #824

Closed
cowboyd opened this issue Feb 4, 2021 · 0 comments · Fixed by #902
Closed

Update guides to show using matchers #824

cowboyd opened this issue Feb 4, 2021 · 0 comments · Fixed by #902
Assignees

Comments

@cowboyd
Copy link
Member

cowboyd commented Feb 4, 2021

With #797 we now have the capability to match powerfully on interactor filters, not just using deepEquals. This means that if you have html that is like:

<p title="In which we greet the user"> Hello User! How are you today?</p>

We don't necessarily want to have to type all of those things in the test case. like:

import { Paragraph } from '@bigtest/interactor';

Paragraph("Hello User! Howe are you today?").has({ title: "In which we greet the user" });

Not only is this ugly, but it's brittle in the event that we want to do something like change the punctuation or capitalization. This is the kind of case that matchers were meant to solve. Matchers can be used both for locators and filters in finding interactors and also for making assertions. Thus, the above could be re-written as:

import { Paragraph, including, matching } from '@bigtest/interactor';

Paragraph(including("Hello")).has({ title: matching(/greet the user$/) });

Not only do we have the including(), and matching() matchers, but there are also combinators: or(), and(), not():

or(containing("Red"), containing("Green"))

And quantifiers some(), every() for working with filters that are iterable:

import { some } from '@bigtest/interactor';

Column("Username").has({ rows: some("cowboyd") });

We need to integrate these matchers into the guides. Maybe even under their own section.

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

Successfully merging a pull request may close this issue.

3 participants