detox 20.10.0 → 20.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Detox-android/com/wix/detox/{20.10.0/detox-20.10.0-javadoc.jar → 20.11.0/detox-20.11.0-javadoc.jar} +0 -0
- package/Detox-android/com/wix/detox/20.11.0/detox-20.11.0-javadoc.jar.md5 +1 -0
- package/Detox-android/com/wix/detox/20.11.0/detox-20.11.0-javadoc.jar.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.11.0/detox-20.11.0-javadoc.jar.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.11.0/detox-20.11.0-javadoc.jar.sha512 +1 -0
- package/Detox-android/com/wix/detox/{20.10.0/detox-20.10.0-sources.jar → 20.11.0/detox-20.11.0-sources.jar} +0 -0
- package/Detox-android/com/wix/detox/20.11.0/detox-20.11.0-sources.jar.md5 +1 -0
- package/Detox-android/com/wix/detox/20.11.0/detox-20.11.0-sources.jar.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.11.0/detox-20.11.0-sources.jar.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.11.0/detox-20.11.0-sources.jar.sha512 +1 -0
- package/Detox-android/com/wix/detox/20.11.0/detox-20.11.0.aar +0 -0
- package/Detox-android/com/wix/detox/20.11.0/detox-20.11.0.aar.md5 +1 -0
- package/Detox-android/com/wix/detox/20.11.0/detox-20.11.0.aar.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.11.0/detox-20.11.0.aar.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.11.0/detox-20.11.0.aar.sha512 +1 -0
- package/Detox-android/com/wix/detox/{20.10.0/detox-20.10.0.pom → 20.11.0/detox-20.11.0.pom} +1 -1
- package/Detox-android/com/wix/detox/20.11.0/detox-20.11.0.pom.md5 +1 -0
- package/Detox-android/com/wix/detox/20.11.0/detox-20.11.0.pom.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.11.0/detox-20.11.0.pom.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.11.0/detox-20.11.0.pom.sha512 +1 -0
- package/Detox-android/com/wix/detox/maven-metadata.xml +4 -4
- package/Detox-android/com/wix/detox/maven-metadata.xml.md5 +1 -1
- package/Detox-android/com/wix/detox/maven-metadata.xml.sha1 +1 -1
- package/Detox-android/com/wix/detox/maven-metadata.xml.sha256 +1 -1
- package/Detox-android/com/wix/detox/maven-metadata.xml.sha512 +1 -1
- package/Detox-ios-src.tbz +0 -0
- package/Detox-ios.tbz +0 -0
- package/android/detox/src/full/java/com/wix/detox/espresso/DetoxMatcher.java +12 -12
- package/android/detox/src/full/java/com/wix/detox/espresso/matcher/RegexMatcher.kt +56 -0
- package/android/detox/src/full/java/com/wix/detox/espresso/matcher/ViewMatchers.kt +16 -4
- package/android/detox/src/testFull/java/com/wix/detox/espresso/matcher/RegexMatcherTest.kt +52 -0
- package/index.d.ts +10 -5
- package/package.json +2 -2
- package/src/android/espressoapi/DetoxMatcher.js +24 -8
- package/src/android/matchers/native.js +9 -4
- package/src/ios/expectTwo.js +8 -7
- package/src/utils/isRegExp.js +7 -0
- package/Detox-android/com/wix/detox/20.10.0/detox-20.10.0-javadoc.jar.md5 +0 -1
- package/Detox-android/com/wix/detox/20.10.0/detox-20.10.0-javadoc.jar.sha1 +0 -1
- package/Detox-android/com/wix/detox/20.10.0/detox-20.10.0-javadoc.jar.sha256 +0 -1
- package/Detox-android/com/wix/detox/20.10.0/detox-20.10.0-javadoc.jar.sha512 +0 -1
- package/Detox-android/com/wix/detox/20.10.0/detox-20.10.0-sources.jar.md5 +0 -1
- package/Detox-android/com/wix/detox/20.10.0/detox-20.10.0-sources.jar.sha1 +0 -1
- package/Detox-android/com/wix/detox/20.10.0/detox-20.10.0-sources.jar.sha256 +0 -1
- package/Detox-android/com/wix/detox/20.10.0/detox-20.10.0-sources.jar.sha512 +0 -1
- package/Detox-android/com/wix/detox/20.10.0/detox-20.10.0.aar +0 -0
- package/Detox-android/com/wix/detox/20.10.0/detox-20.10.0.aar.md5 +0 -1
- package/Detox-android/com/wix/detox/20.10.0/detox-20.10.0.aar.sha1 +0 -1
- package/Detox-android/com/wix/detox/20.10.0/detox-20.10.0.aar.sha256 +0 -1
- package/Detox-android/com/wix/detox/20.10.0/detox-20.10.0.aar.sha512 +0 -1
- package/Detox-android/com/wix/detox/20.10.0/detox-20.10.0.pom.md5 +0 -1
- package/Detox-android/com/wix/detox/20.10.0/detox-20.10.0.pom.sha1 +0 -1
- package/Detox-android/com/wix/detox/20.10.0/detox-20.10.0.pom.sha256 +0 -1
- package/Detox-android/com/wix/detox/20.10.0/detox-20.10.0.pom.sha512 +0 -1
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
f0cf6ad0def43fbab5ba6fae7b4e5441
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
48b29f67227c7b45844172ffdc0b25c7e5bd4f05
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0dbfb89e22024b3c3f45e0941a9fd3421d6a4f4041b76f8f54edd4259a9092a8
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
a1a2706b699d0c9217252c287a3d82b679bb206423ebbee820a261cd5925970426596f99a16fdcd8d37107185c3d5ec80628dd48309d0c31c89a00a37f7bf292
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3579eb8ea896facf3fd7e2be627cdc03
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
1fb720e2b0f0da39406134aabcdafec756f9cbe5
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
f1c18496d23e09cffc96ef1b3bcbf349b1ae0a020ed5a6707b64bf22e30d9180
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ebfcaef97fb6aa02bbda14d12a26eaac823620766c7e3b84eee7fa0115edb17463ea59ac689d07ffc97e84d2dbdbbd7db3014fdd976d0b2dd207c6278494f523
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
518f621bfc037203c5ddd30c3f62c8ad
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
65065fce4ddace8e95d235b60cf5a27f93e1162b
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
cd516e30305ad672e7ed0e8b4f77e992482c9a2979ce92d88a074dc45524cbe9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
00ff273c46cb32923f574fd00189459e9dff6d4782ac561f30583c9610427e270450783485aece4e9ebeb52c12bd3eec1560521d5a0535965dd278c7b44f3848
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<modelVersion>4.0.0</modelVersion>
|
|
4
4
|
<groupId>com.wix</groupId>
|
|
5
5
|
<artifactId>detox</artifactId>
|
|
6
|
-
<version>20.
|
|
6
|
+
<version>20.11.0</version>
|
|
7
7
|
<packaging>aar</packaging>
|
|
8
8
|
<name>Detox</name>
|
|
9
9
|
<description>Gray box end-to-end testing and automation library for mobile apps</description>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
72868177d685cfd9912ca8fe3c08da3a
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ad0ed20f218ec25f055f5c668c9b6dcd875069bf
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
b1c48d9cf1df54b6cbe27c45a4c8834162b04a783601a3d4b030fd3ac12e723e
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
c68e22610d04ad949b65cffe6305e30bab93ca1a10d53d0cd3ded77dee8f64d7d14f1b250cbdde553a06a4fe5b50738af7ae363b5f7ad836f816f48ca845d189
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
<groupId>com.wix</groupId>
|
|
4
4
|
<artifactId>detox</artifactId>
|
|
5
5
|
<versioning>
|
|
6
|
-
<latest>20.
|
|
7
|
-
<release>20.
|
|
6
|
+
<latest>20.11.0</latest>
|
|
7
|
+
<release>20.11.0</release>
|
|
8
8
|
<versions>
|
|
9
|
-
<version>20.
|
|
9
|
+
<version>20.11.0</version>
|
|
10
10
|
</versions>
|
|
11
|
-
<lastUpdated>
|
|
11
|
+
<lastUpdated>20230704204300</lastUpdated>
|
|
12
12
|
</versioning>
|
|
13
13
|
</metadata>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
e930da2d4686f5b8bbe2fe5638fab155
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
7ec428486d1d978a16101aedc506e79483ccf63a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
469a65278a6ed368df597dfb505c150591e4ab587b190dbee2bb12c50b41a6ef
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
dfc9bd1f96626dee848008639fc467b70d4653f57761c30cff16f41550d1f2a79dcd9aefd64c7313b8672c503e1a12dc360b1742faba6e2946878f6b2f8bbaac
|
package/Detox-ios-src.tbz
CHANGED
|
Binary file
|
package/Detox-ios.tbz
CHANGED
|
Binary file
|
|
@@ -14,10 +14,10 @@ import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
|
|
|
14
14
|
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayingAtLeast;
|
|
15
15
|
import static androidx.test.espresso.matcher.ViewMatchers.isFocused;
|
|
16
16
|
import static androidx.test.espresso.matcher.ViewMatchers.isNotChecked;
|
|
17
|
-
import static androidx.test.espresso.matcher.ViewMatchers.withContentDescription;
|
|
18
17
|
import static androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility;
|
|
19
|
-
import static
|
|
20
|
-
import static
|
|
18
|
+
import static com.wix.detox.espresso.matcher.ViewMatchers.withTagValue;
|
|
19
|
+
import static com.wix.detox.espresso.matcher.ViewMatchers.withContentDescription;
|
|
20
|
+
import static com.wix.detox.espresso.matcher.ViewMatchers.withText;
|
|
21
21
|
import static com.wix.detox.espresso.matcher.ViewMatchers.isMatchingAtIndex;
|
|
22
22
|
import static com.wix.detox.espresso.matcher.ViewMatchers.isOfClassName;
|
|
23
23
|
import static com.wix.detox.espresso.matcher.ViewMatchers.toHaveSliderPosition;
|
|
@@ -40,25 +40,25 @@ public class DetoxMatcher {
|
|
|
40
40
|
// static class
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
public static Matcher<View> matcherForText(String text) {
|
|
43
|
+
public static Matcher<View> matcherForText(String text, boolean isRegex) {
|
|
44
44
|
// return anyOf(withText(text), withContentDescription(text));
|
|
45
|
-
return allOf(withText(text), withEffectiveVisibility(Visibility.VISIBLE));
|
|
45
|
+
return allOf(withText(text, isRegex), withEffectiveVisibility(Visibility.VISIBLE));
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
public static Matcher<View> matcherForAccessibilityLabel(String label) {
|
|
49
|
-
return allOf(withAccessibilityLabel(label), withEffectiveVisibility(Visibility.VISIBLE));
|
|
48
|
+
public static Matcher<View> matcherForAccessibilityLabel(String label, boolean isRegex) {
|
|
49
|
+
return allOf(withAccessibilityLabel(label, isRegex), withEffectiveVisibility(Visibility.VISIBLE));
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
public static Matcher<View> matcherForShallowAccessibilityLabel(String label) {
|
|
53
|
-
return allOf(withShallowAccessibilityLabel(label), withEffectiveVisibility(Visibility.VISIBLE));
|
|
52
|
+
public static Matcher<View> matcherForShallowAccessibilityLabel(String label, boolean isRegex) {
|
|
53
|
+
return allOf(withShallowAccessibilityLabel(label, isRegex), withEffectiveVisibility(Visibility.VISIBLE));
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
public static Matcher<View> matcherForContentDescription(String contentDescription) {
|
|
57
|
-
return allOf(withContentDescription(contentDescription), withEffectiveVisibility(Visibility.VISIBLE));
|
|
57
|
+
return allOf(withContentDescription(contentDescription, false), withEffectiveVisibility(Visibility.VISIBLE));
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
public static Matcher<View> matcherForTestId(String testId) {
|
|
61
|
-
return allOf(withTagValue(
|
|
60
|
+
public static Matcher<View> matcherForTestId(String testId, boolean isRegex) {
|
|
61
|
+
return allOf(withTagValue(testId, isRegex), withEffectiveVisibility(Visibility.VISIBLE));
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
public static Matcher<View> matcherForToggleable(boolean value) {
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
package com.wix.detox.espresso.matcher
|
|
2
|
+
|
|
3
|
+
import org.hamcrest.Description
|
|
4
|
+
import org.hamcrest.TypeSafeMatcher
|
|
5
|
+
|
|
6
|
+
class RegexMatcher<T>(private val jsRegex: String) : TypeSafeMatcher<T>() {
|
|
7
|
+
override fun matchesSafely(item: T): Boolean {
|
|
8
|
+
val stringItem = item.toString()
|
|
9
|
+
return stringItem.matchesJSRegex(jsRegex)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
override fun describeTo(description: Description) {
|
|
13
|
+
description.appendText("should match the pattern: $jsRegex")
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Returns whether the whole string matches the given `jsRegex`.
|
|
18
|
+
// JS flags has the format of `/<pattern>/<flags>`.
|
|
19
|
+
// Flags can be either:
|
|
20
|
+
// - i: With this flag the search is case-insensitive: no difference between A and a (see the example below).
|
|
21
|
+
// - s: Enables “dotall” mode, that allows a dot . to match newline character \n (covered in the chapter Character classes).
|
|
22
|
+
// - m: Multiline mode (covered in the chapter Multiline mode of anchors ^ $, flag "m").
|
|
23
|
+
// Other flags (e.g. g,u,s) are not supported as they do not have equivalents in Kotlin.
|
|
24
|
+
//
|
|
25
|
+
// - See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
|
|
26
|
+
fun String.matchesJSRegex(jsRegex: String): Boolean {
|
|
27
|
+
val flagsChars = getRegexFlags(jsRegex)
|
|
28
|
+
val options = getRegexOptions(flagsChars)
|
|
29
|
+
val pattern = getRegexPattern(jsRegex)
|
|
30
|
+
return Regex(pattern, options).matches(this)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
private fun getRegexFlags(jsRegex: String): CharSequence {
|
|
34
|
+
return jsRegex.substringAfterLast("/")
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
private fun getRegexPattern(jsRegex: String): String {
|
|
38
|
+
val pattern = jsRegex.substringAfter("/")
|
|
39
|
+
return pattern.substringBeforeLast("/")
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
private fun getRegexOptions(flagsChars: CharSequence): MutableSet<RegexOption> {
|
|
43
|
+
val options = mutableSetOf<RegexOption>()
|
|
44
|
+
|
|
45
|
+
if (flagsChars.contains('i', ignoreCase = true)) {
|
|
46
|
+
options.add(RegexOption.IGNORE_CASE)
|
|
47
|
+
}
|
|
48
|
+
if (flagsChars.contains('s', ignoreCase = true)) {
|
|
49
|
+
options.add(RegexOption.DOT_MATCHES_ALL)
|
|
50
|
+
}
|
|
51
|
+
if (flagsChars.contains('m', ignoreCase = true)) {
|
|
52
|
+
options.add(RegexOption.MULTILINE)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return options
|
|
56
|
+
}
|
|
@@ -11,16 +11,28 @@ import com.wix.detox.espresso.common.SliderHelper
|
|
|
11
11
|
import org.hamcrest.*
|
|
12
12
|
import org.hamcrest.Matchers.*
|
|
13
13
|
import kotlin.math.abs
|
|
14
|
+
import org.hamcrest.CoreMatchers.`is`
|
|
14
15
|
|
|
15
16
|
/*
|
|
16
17
|
* An extension of [androidx.test.espresso.matcher.ViewMatchers].
|
|
17
18
|
*/
|
|
19
|
+
fun <T> getRelevantMatcher(value: T, isRegex: Boolean): Matcher<T> =
|
|
20
|
+
if (isRegex) RegexMatcher(value.toString()) else `is`(value)
|
|
18
21
|
|
|
19
|
-
fun withAccessibilityLabel(text: String) =
|
|
20
|
-
WithAccessibilityLabelMatcher(
|
|
22
|
+
fun withAccessibilityLabel(text: String, isRegex: Boolean): Matcher<View> =
|
|
23
|
+
WithAccessibilityLabelMatcher(getRelevantMatcher(text, isRegex))
|
|
21
24
|
|
|
22
|
-
fun withShallowAccessibilityLabel(label: String): Matcher<View>
|
|
23
|
-
|
|
25
|
+
fun withShallowAccessibilityLabel(label: String, isRegex: Boolean): Matcher<View> =
|
|
26
|
+
anyOf(withContentDescription(label, isRegex), withText(label, isRegex))
|
|
27
|
+
|
|
28
|
+
fun withText(text: String, isRegex: Boolean): Matcher<View> =
|
|
29
|
+
ViewMatchers.withText(getRelevantMatcher(text, isRegex))
|
|
30
|
+
|
|
31
|
+
fun withContentDescription(label: String, isRegex: Boolean): Matcher<View> =
|
|
32
|
+
ViewMatchers.withContentDescription(getRelevantMatcher(label, isRegex))
|
|
33
|
+
|
|
34
|
+
fun withTagValue(testId: String, isRegex: Boolean): Matcher<View> =
|
|
35
|
+
ViewMatchers.withTagValue(getRelevantMatcher<Any>(testId, isRegex))
|
|
24
36
|
|
|
25
37
|
fun isOfClassName(className: String): Matcher<View> {
|
|
26
38
|
try {
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
package com.wix.detox.espresso.matcher
|
|
2
|
+
|
|
3
|
+
import org.junit.Test
|
|
4
|
+
import kotlin.test.assertFalse
|
|
5
|
+
import kotlin.test.assertTrue
|
|
6
|
+
import org.junit.runner.RunWith
|
|
7
|
+
import org.robolectric.RobolectricTestRunner
|
|
8
|
+
|
|
9
|
+
@RunWith(RobolectricTestRunner::class)
|
|
10
|
+
class RegexMatcherTest {
|
|
11
|
+
@Test
|
|
12
|
+
fun `should work with string matching regex`() {
|
|
13
|
+
val input = "Hello, world!"
|
|
14
|
+
val regex = "/[A-Z][a-z]+, world!/"
|
|
15
|
+
assertTrue(input.matchesJSRegex(regex))
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
@Test
|
|
19
|
+
fun `should work with string not matching regex`() {
|
|
20
|
+
val input = "Hello, world!"
|
|
21
|
+
val regex = "/[A-Z]+, world!/"
|
|
22
|
+
assertFalse(input.matchesJSRegex(regex))
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@Test
|
|
26
|
+
fun `should work with the 'i' flag`() {
|
|
27
|
+
val input = "Hello, world!"
|
|
28
|
+
val regex = "/[A-Z]+, woRlD!/i"
|
|
29
|
+
assertTrue(input.matchesJSRegex(regex))
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@Test
|
|
33
|
+
fun `should work with the 's' flag`() {
|
|
34
|
+
val input = "Hello,\nworld!"
|
|
35
|
+
val regex = "/Hello,\\sworld!/s"
|
|
36
|
+
assertTrue(input.matchesJSRegex(regex))
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@Test
|
|
40
|
+
fun `should work with the 'm' flag`() {
|
|
41
|
+
val input = "Hello,\nworld!"
|
|
42
|
+
val regex = "/^Hello,\\s.*!$/m"
|
|
43
|
+
assertTrue(input.matchesJSRegex(regex))
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@Test
|
|
47
|
+
fun `should work with multiple flags, ignore casing`() {
|
|
48
|
+
val input = "Hello,\nworld!"
|
|
49
|
+
val regex = "/^heLLo,\\swOrld!/ISM"
|
|
50
|
+
assertTrue(input.matchesJSRegex(regex))
|
|
51
|
+
}
|
|
52
|
+
}
|
package/index.d.ts
CHANGED
|
@@ -971,20 +971,25 @@ declare global {
|
|
|
971
971
|
* <TouchableOpacity testID={'tap_me'}>
|
|
972
972
|
* // Then match with by.id:
|
|
973
973
|
* await element(by.id('tap_me'));
|
|
974
|
+
* await element(by.id(/^tap_[a-z]+$/));
|
|
974
975
|
*/
|
|
975
|
-
id(id: string): NativeMatcher;
|
|
976
|
+
id(id: string | RegExp): NativeMatcher;
|
|
976
977
|
|
|
977
978
|
/**
|
|
978
979
|
* Find an element by text, useful for text fields, buttons.
|
|
979
|
-
* @example
|
|
980
|
+
* @example
|
|
981
|
+
* await element(by.text('Tap Me'));
|
|
982
|
+
* await element(by.text(/^Tap .*$/));
|
|
980
983
|
*/
|
|
981
|
-
text(text: string): NativeMatcher;
|
|
984
|
+
text(text: string | RegExp): NativeMatcher;
|
|
982
985
|
|
|
983
986
|
/**
|
|
984
987
|
* Find an element by accessibilityLabel on iOS, or by contentDescription on Android.
|
|
985
|
-
* @example
|
|
988
|
+
* @example
|
|
989
|
+
* await element(by.label('Welcome'));
|
|
990
|
+
* await element(by.label(/[a-z]+/i));
|
|
986
991
|
*/
|
|
987
|
-
label(label: string): NativeMatcher;
|
|
992
|
+
label(label: string | RegExp): NativeMatcher;
|
|
988
993
|
|
|
989
994
|
/**
|
|
990
995
|
* Find an element by native view type.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "detox",
|
|
3
3
|
"description": "E2E tests and automation for mobile",
|
|
4
|
-
"version": "20.
|
|
4
|
+
"version": "20.11.0",
|
|
5
5
|
"bin": {
|
|
6
6
|
"detox": "local-cli/cli.js"
|
|
7
7
|
},
|
|
@@ -206,5 +206,5 @@
|
|
|
206
206
|
"browserslist": [
|
|
207
207
|
"node 14"
|
|
208
208
|
],
|
|
209
|
-
"gitHead": "
|
|
209
|
+
"gitHead": "e132a02242f1a4ebcf1775ba4ceb782d5b1a855c"
|
|
210
210
|
}
|
|
@@ -14,39 +14,51 @@ function sanitize_matcher(matcher) {
|
|
|
14
14
|
return originalMatcher.type ? originalMatcher.value : originalMatcher;
|
|
15
15
|
}
|
|
16
16
|
class DetoxMatcher {
|
|
17
|
-
static matcherForText(text) {
|
|
17
|
+
static matcherForText(text, isRegex) {
|
|
18
18
|
if (typeof text !== "string") throw new Error("text should be a string, but got " + (text + (" (" + (typeof text + ")"))));
|
|
19
|
+
if (typeof isRegex !== "boolean") throw new Error("isRegex should be a boolean, but got " + (isRegex + (" (" + (typeof isRegex + ")"))));
|
|
19
20
|
return {
|
|
20
21
|
target: {
|
|
21
22
|
type: "Class",
|
|
22
23
|
value: "com.wix.detox.espresso.DetoxMatcher"
|
|
23
24
|
},
|
|
24
25
|
method: "matcherForText",
|
|
25
|
-
args: [text
|
|
26
|
+
args: [text, {
|
|
27
|
+
type: "boolean",
|
|
28
|
+
value: isRegex
|
|
29
|
+
}]
|
|
26
30
|
};
|
|
27
31
|
}
|
|
28
32
|
|
|
29
|
-
static matcherForAccessibilityLabel(label) {
|
|
33
|
+
static matcherForAccessibilityLabel(label, isRegex) {
|
|
30
34
|
if (typeof label !== "string") throw new Error("label should be a string, but got " + (label + (" (" + (typeof label + ")"))));
|
|
35
|
+
if (typeof isRegex !== "boolean") throw new Error("isRegex should be a boolean, but got " + (isRegex + (" (" + (typeof isRegex + ")"))));
|
|
31
36
|
return {
|
|
32
37
|
target: {
|
|
33
38
|
type: "Class",
|
|
34
39
|
value: "com.wix.detox.espresso.DetoxMatcher"
|
|
35
40
|
},
|
|
36
41
|
method: "matcherForAccessibilityLabel",
|
|
37
|
-
args: [label
|
|
42
|
+
args: [label, {
|
|
43
|
+
type: "boolean",
|
|
44
|
+
value: isRegex
|
|
45
|
+
}]
|
|
38
46
|
};
|
|
39
47
|
}
|
|
40
48
|
|
|
41
|
-
static matcherForShallowAccessibilityLabel(label) {
|
|
49
|
+
static matcherForShallowAccessibilityLabel(label, isRegex) {
|
|
42
50
|
if (typeof label !== "string") throw new Error("label should be a string, but got " + (label + (" (" + (typeof label + ")"))));
|
|
51
|
+
if (typeof isRegex !== "boolean") throw new Error("isRegex should be a boolean, but got " + (isRegex + (" (" + (typeof isRegex + ")"))));
|
|
43
52
|
return {
|
|
44
53
|
target: {
|
|
45
54
|
type: "Class",
|
|
46
55
|
value: "com.wix.detox.espresso.DetoxMatcher"
|
|
47
56
|
},
|
|
48
57
|
method: "matcherForShallowAccessibilityLabel",
|
|
49
|
-
args: [label
|
|
58
|
+
args: [label, {
|
|
59
|
+
type: "boolean",
|
|
60
|
+
value: isRegex
|
|
61
|
+
}]
|
|
50
62
|
};
|
|
51
63
|
}
|
|
52
64
|
|
|
@@ -62,15 +74,19 @@ class DetoxMatcher {
|
|
|
62
74
|
};
|
|
63
75
|
}
|
|
64
76
|
|
|
65
|
-
static matcherForTestId(testId) {
|
|
77
|
+
static matcherForTestId(testId, isRegex) {
|
|
66
78
|
if (typeof testId !== "string") throw new Error("testId should be a string, but got " + (testId + (" (" + (typeof testId + ")"))));
|
|
79
|
+
if (typeof isRegex !== "boolean") throw new Error("isRegex should be a boolean, but got " + (isRegex + (" (" + (typeof isRegex + ")"))));
|
|
67
80
|
return {
|
|
68
81
|
target: {
|
|
69
82
|
type: "Class",
|
|
70
83
|
value: "com.wix.detox.espresso.DetoxMatcher"
|
|
71
84
|
},
|
|
72
85
|
method: "matcherForTestId",
|
|
73
|
-
args: [testId
|
|
86
|
+
args: [testId, {
|
|
87
|
+
type: "boolean",
|
|
88
|
+
value: isRegex
|
|
89
|
+
}]
|
|
74
90
|
};
|
|
75
91
|
}
|
|
76
92
|
|
|
@@ -1,26 +1,30 @@
|
|
|
1
1
|
const DetoxRuntimeError = require('../../errors/DetoxRuntimeError');
|
|
2
2
|
const invoke = require('../../invoke');
|
|
3
|
+
const { isRegExp } = require('../../utils/isRegExp');
|
|
3
4
|
const { NativeMatcher } = require('../core/NativeMatcher');
|
|
4
5
|
const DetoxMatcherApi = require('../espressoapi/DetoxMatcher');
|
|
5
6
|
|
|
6
7
|
class LabelMatcher extends NativeMatcher {
|
|
7
8
|
constructor(value) {
|
|
8
9
|
super();
|
|
9
|
-
|
|
10
|
+
const isRegex = isRegExp(value);
|
|
11
|
+
this._call = invoke.callDirectly(DetoxMatcherApi.matcherForAccessibilityLabel(isRegex ? value.toString() : value, isRegex));
|
|
10
12
|
}
|
|
11
13
|
}
|
|
12
14
|
|
|
13
15
|
class ShallowLabelMatcher extends NativeMatcher {
|
|
14
16
|
constructor(value) {
|
|
15
17
|
super();
|
|
16
|
-
|
|
18
|
+
const isRegex = isRegExp(value);
|
|
19
|
+
this._call = invoke.callDirectly(DetoxMatcherApi.matcherForShallowAccessibilityLabel(isRegex ? value.toString() : value, isRegex));
|
|
17
20
|
}
|
|
18
21
|
}
|
|
19
22
|
|
|
20
23
|
class IdMatcher extends NativeMatcher {
|
|
21
24
|
constructor(value) {
|
|
22
25
|
super();
|
|
23
|
-
|
|
26
|
+
const isRegex = isRegExp(value);
|
|
27
|
+
this._call = invoke.callDirectly(DetoxMatcherApi.matcherForTestId(isRegex ? value.toString() : value, isRegex));
|
|
24
28
|
}
|
|
25
29
|
}
|
|
26
30
|
|
|
@@ -53,7 +57,8 @@ class ExistsMatcher extends NativeMatcher {
|
|
|
53
57
|
class TextMatcher extends NativeMatcher {
|
|
54
58
|
constructor(value) {
|
|
55
59
|
super();
|
|
56
|
-
|
|
60
|
+
const isRegex = isRegExp(value);
|
|
61
|
+
this._call = invoke.callDirectly(DetoxMatcherApi.matcherForText(isRegex ? value.toString() : value, isRegex));
|
|
57
62
|
}
|
|
58
63
|
}
|
|
59
64
|
|
package/src/ios/expectTwo.js
CHANGED
|
@@ -9,6 +9,7 @@ const tempfile = require('tempfile');
|
|
|
9
9
|
const { assertEnum, assertNormalized } = require('../utils/assertArgument');
|
|
10
10
|
const { removeMilliseconds } = require('../utils/dateUtils');
|
|
11
11
|
const { actionDescription, expectDescription } = require('../utils/invocationTraceDescriptions');
|
|
12
|
+
const { isRegExp } = require('../utils/isRegExp');
|
|
12
13
|
const log = require('../utils/logger').child({ cat: 'ws-client, ws' });
|
|
13
14
|
const traceInvocationCall = require('../utils/traceInvocationCall').bind(null, log);
|
|
14
15
|
|
|
@@ -231,7 +232,7 @@ class Element {
|
|
|
231
232
|
|
|
232
233
|
performAccessibilityAction(actionName) {
|
|
233
234
|
if (typeof actionName !== 'string') throw new Error('actionName should be a string, but got ' + (actionName + (' (' + (typeof actionName + ')'))));
|
|
234
|
-
|
|
235
|
+
|
|
235
236
|
const traceDescription = actionDescription.performAccessibilityAction(actionName);
|
|
236
237
|
return this.withAction('accessibilityAction', traceDescription, actionName);
|
|
237
238
|
}
|
|
@@ -409,14 +410,14 @@ class Matcher {
|
|
|
409
410
|
}
|
|
410
411
|
|
|
411
412
|
label(label) {
|
|
412
|
-
if (typeof label !== 'string') throw new Error('label should be a string, but got ' + (label + (' (' + (typeof label + ')'))));
|
|
413
|
-
this.predicate = { type: 'label', value: label };
|
|
413
|
+
if (typeof label !== 'string' && !isRegExp(label)) throw new Error('label should be a string or regex, but got ' + (label + (' (' + (typeof label + ')'))));
|
|
414
|
+
this.predicate = { type: 'label', value: label.toString(), isRegex: isRegExp(label) };
|
|
414
415
|
return this;
|
|
415
416
|
}
|
|
416
417
|
|
|
417
418
|
id(id) {
|
|
418
|
-
if (typeof id !== 'string') throw new Error('id should be a string, but got ' + (id + (' (' + (typeof id + ')'))));
|
|
419
|
-
this.predicate = { type: 'id', value: id };
|
|
419
|
+
if (typeof id !== 'string' && !isRegExp(id)) throw new Error('id should be a string or regex, but got ' + (id + (' (' + (typeof id + ')'))));
|
|
420
|
+
this.predicate = { type: 'id', value: id.toString(), isRegex: isRegExp(id) };
|
|
420
421
|
return this;
|
|
421
422
|
}
|
|
422
423
|
|
|
@@ -439,8 +440,8 @@ class Matcher {
|
|
|
439
440
|
}
|
|
440
441
|
|
|
441
442
|
text(text) {
|
|
442
|
-
if (typeof text !== 'string') throw new Error(
|
|
443
|
-
this.predicate = { type: 'text', value: text };
|
|
443
|
+
if (typeof text !== 'string' && !isRegExp(text)) throw new Error(`text should be a string or regex, but got ` + (text + (' (' + (typeof text + ')'))));
|
|
444
|
+
this.predicate = { type: 'text', value: text.toString(), isRegex: isRegExp(text) };
|
|
444
445
|
return this;
|
|
445
446
|
}
|
|
446
447
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
ccec694db9b1c0c103c091b99e7ee9df
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
802f3fb4dd671a6541a6eca43689bc8601886e9b
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
11a86d1948d439bc47acdc0418dfa08494d571845cbfb3689eadc2da28cf5836
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
fe9e28217fa01605deb67e3df29773a045d6aa29ffa7f63d2e982df79dfd6a5e6afc54ce48f486ec056f93004a481e0c7ec302f5674c4038feab8ba1c2f96fda
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
5cdc018bfde6bf33c25761e6a5ed339b
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
cd978c712a0737b5d5873c4fe60f2a1417617421
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
2288f87a57ef315c097ace78d834b5f29cbe7db7d96daaab40379b14e269681a
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
2f85eadd8a1447747c1a260d256d56c6dc42fa9d315e9bca09dc7dec5f212b2ea00fd570ee2000bd473c506b38dc7b7557ddddd98376ecb14ba9bc4f63ac9122
|
|
Binary file
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
b1d894d9d707154e6edb6f993adae08a
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
f25b33bfa236d17cc6600fe6adb5df32faefa70e
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
0621fa6efd25f58c71db3b666b109de6dd838c16a833dd2f9f6f3d3aaceb2017
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
6166f3c56b5d4d7ab27f77dd70cf17335d3e6a44875ffded704ca56872a2ba7e36a3e2a4450bf751cf5c19d71fe65fb23a8d702d847398b90c7c7531186c0ab7
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
692cbd42d3869003441e9aa9386fbddd
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
d9e2fbaff2dd25b569381c0f415841d5705a5e85
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
57ce34871cc1b500ba04fc4a11e51521862d79c0a03cc69807723266e64d5b45
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
8e513071ae098fd57278692d0dcea073a498f649ef76c8f1c12a88fd53e1ed893e082623b5ae760aa74f301c60779335b18d71f729876885b18a9aa48b0db827
|