question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

(WIP) Support regex in matchers

See original GitHub issue

Describe your idea

Support regular expression in Detox matchers

Specifically in by.text(), by.label(). This can be useful since text and labels may include dynamic content (e.g. date).

Also, I suggest to change the current API, from: https://github.com/wix/Detox/blob/246317d3ee5b7587bb966c78204b5def5b72dfaf/detox/index.d.ts#L804

To:

text(text: string | RegExp): NativeMatcher;

Usage example

This code will find an element with the text "The year is 2023", if exists:

const someElement = element(by.text(/The year is: \d{4}/));

While this code won’t:

const someElement = element(by.text('The year is: \d{4}'));

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:10
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
noomorphcommented, May 2, 2022

@asafkorem the only pitfall I see is that we might need to standardize RegExp mechanisms between iOS/Android/JS…

1reaction
d4vidicommented, May 3, 2022

Nevertheless I’d like this kind of an API to come with a warning of some sort, that would explain that ideally, whichever text we trying to match should be deterministic to the point it can be predetermined down to the character. Of course, this is not always the case in unmocked tests, but generally this should be the preferred situation.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[WIP] lib: regexp matching in 'subject' and 'from' - notmuch
Date is already searchable, and message_id is not obviously useful to regex match. This was originally written by Austin Clements, ...
Read more >
Everything You Need to Know About Regex (WIP) - sab codes
Regex is ran using a regex engine. A regex engine has support for finding, replacing, validating, and splitting. Many programs you are already ......
Read more >
TRE regular expression library - IBM
Use the TRE regular expression library to run search queries on both single-byte and multi-byte character languages. The TRE regular expression library supports...
Read more >
mvr wip - regex101
Regular expression tester with syntax highlighting, explanation, cheat sheet for PHP/PCRE, Python, GO, JavaScript, Java, C#/.NET.
Read more >
iWAF Exceptions with Regex Matching for Arguments
This article discusses configuring iWAF exceptions with regex matching for arguments. Avi Vantage supports Regex for URL matching. Avi iWAF uses PCRE (Perl ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found