Tim Malseed
05/01/2023, 3:08 AMtestTag
to the same modifier means that onNodeWithTag
fails for subsequent test tags?
e.g.
fun RootScreen() {
SomeScreen(modifier = Modifier.semantics { testTag = "tag_a" }
}
fun SomeScreen(modifier: Modifier) {
Scaffold (modifier = modifier.semantics { testTag = "test_b" }) { ...
}
A test with onNodeWithTag("test_b")
fails. But if I remove tag_a
, it succeeds.Tim Malseed
05/01/2023, 3:08 AMuseUnmergedTree
or notTim Malseed
05/01/2023, 3:15 AMSemanticsProperties
code:
val TestTag = SemanticsPropertyKey<String>(
name = "TestTag",
mergePolicy = { parentValue, _ ->
// Never merge TestTags, to avoid leaking internal test tags to parents.
parentValue
}
)
It’s interesting, the ‘merge policy’ seems to say ‘only ever use the parent value’
I’m going to guess that means if there’s a conflict when adding a tag, then the tag is ignored and the original tag is retained