Join us from October 8-10 in New York City to learn the latest tips, trends, and news about GraphQL Federation and API platform engineering.Join us for GraphQL Summit 2024 in NYC
Docs
Start for Free

UI Tests


provides a built-in IdlingResource to help you write UI tests with Espresso. The ApolloIdlingResource makes sure that your tests wait for your queries to terminate before proceeding.

Add the apollo-idling-resource dependency:

build.gradle[.kts]
implementation("com.apollographql.apollo3:apollo-idling-resource:3.8.5")

If you have multiple ApolloClients, you need to create and register a different ApolloIdlingResource with a different name for each. Registering multiple IdlingResources with the same name will cause your test suite to crash.

// Create your IdlingResource
val idlingResource = ApolloIdlingResource("apolloIdlingResource")
// Register the idlingResource before running your tests (once per client).
IdlingRegistry.getInstance().register(idlingResource)
// Intruct your ApolloClient to update the IdlingResource
val apolloClient = ApolloClient.Builder()
.serverUrl("https://example.com/graphql")
.idlingResource(idlingResource)
.build()

In the example above, all executed by apolloClient (except , which might run for a long time) will update the IdlingResource so that no automatic actions take place while your app is waiting for data.

Previous
Data builders
Next
Uploading files
Rate articleRateEdit on GitHubEditForumsDiscord

© 2024 Apollo Graph Inc., d/b/a Apollo GraphQL.

Privacy Policy

Company