title: Datastore instrumented test fails with kotlinx.coroutines.test.UncompletedCoroutinesError
body: <p>Running Datastore instrumented test fails with
  kotlinx.coroutines.test.UncompletedCoroutinesError: After waiting for 60000 ms, the test coroutine is not completing, there were active child jobs: [ScopeCoroutine{Active}@e24f0d2]</p>
  <p>So far Tried to:</p>
  <ol>
  <li>Use runBlockingTest or runBlocking instead of runTest</li>
  <li>Tried to call runBlocking/runBlockingTest and runTest by the testDispatcher</li>
  <li>Changed the context of runTest</li>
  <li>Launched the collection of flow in test and consumed it before finally cancelling the job</li>
  <li>Tried to use Flow Terminal operators (e.g. first(), take()) to test flow instead of turbine test</li>
  </ol>
  <p><strong>TestAppModule</strong></p>
  <pre><code>@Module
  @TestInstallIn(components = [SingletonComponent::class], replaces = [LocalModule::class])
  object TestAppModule {
  
      //...
  
      @OptIn(ExperimentalCoroutinesApi::class)
      @Singleton
      @Provides
      fun provideFakePreferences(
          @ApplicationContext context: Context,
      ): DataStore&lt;Preferences&gt; {
  
          return PreferenceDataStoreFactory
              .create(
                  scope = TestScope(),
                  produceFile = {
                      context.preferencesDataStoreFile(&quot;test_pref_file&quot;)
                  }
              )
      }
  
  }
  </code></pre>
  <p><strong>RepoPreferencesTest</strong></p>
  <pre><code>@OptIn(ExperimentalCoroutinesApi::class)
  @HiltAndroidTest
  @RunWith(AndroidJUnit4::class)
  class RepoPreferencesTest {
  
      @get:Rule
      val hiltRule = HiltAndroidRule(this)
  
      @Inject
      lateinit var testDataStore: DataStore&lt;Preferences&gt;
  
      lateinit var repoPreferences: RepoPreferences
  
      private val testCoroutineDispatcher = UnconfinedTestDispatcher()
  
      private val testCoroutineScope = TestScope(testCoroutineDispatcher + Job())
  
      @Before
      fun setup() {
          hiltRule.inject()
  
          repoPreferences = RepoPreferencesImpl(testDataStore)
      }
  
  
      @Test
      fun getInitialLanguageFromInitially_ReturnsDefaultValue() = runTest {
          repoPreferences.language.test {
              assertThat(awaitItem()).isEqualTo(RemoteConstants.DEFAULT_LANGUAGE)
              cancelAndIgnoreRemainingEvents()
          }
      }
  
      //...
  }
  </code></pre>