Skip to main content

TestProvider

Used to determine strategy for testing

Submit feedback
github
import { TestProvider } from '@uhg-abyss/mobile';

The TestProvider is a component that provides a context for testing purposes. It allows you to specify a strategy for testing, which can be either "root" or "class". The provider wraps the rest of the component tree and applies the specified strategy.

Class strategy (default)

The "class" strategy (similar to default) allows testing of nested components by appending the Abyss class name to your testID. This creates unique identifiers for each element within the component.

For example, let's say the testID of ProgressBar is set to "your-test-ID".

<TestProvider strategy="class">
<ProgressBar testID="your-test-ID" />
</TestProvider>

We can then refer to the classes for the ProgressBar.

ProgressBar Classes

Class NameDescription
abyss-progress-bar-rootProgress bar root element
abyss-progress-bar-slideProgress bar slide

The resulting test IDs will be "your-test-ID-abyss-progress-bar-root" & "your-test-ID-abyss-progress-bar-slide".

Root strategy

The "root" strategy applies the testID only to the root element of the component. This means you won't be able to target nested elements within the Abyss component for testing.

For example, let's say the testID of ProgressBar is set to "your-test-ID".

<TestProvider strategy="root">
<ProgressBar testID="your-test-ID" />
</TestProvider>

The resulting testID will still be "your-test-ID".

TestProvider Props

Prop NameTypeDefaultDescription
childrennode-The rest of the component tree
strategy"root" | "class"-The strategy to use for testing
Table of Contents