title: MockK mock ViewModel's savedStateHandle.getLiveData()
body: <p>I'm trying to test this ViewModel with savedStateHandle</p>
  <pre><code>class PostListViewModel @ViewModelInject constructor(
      private val coroutineScope: CoroutineScope,
      private val getPostsUseCase: GetPostListUseCaseFlow,
      @Assisted savedStateHandle: SavedStateHandle
  ) : AbstractPostListVM() {
  
      private val _goToDetailScreen =
          savedStateHandle.getLiveData&lt;Event&lt;Post&gt;&gt;(POST_DETAIL)
  //        MutableLiveData&lt;Event&lt;Post&gt;&gt;()
  
      override val goToDetailScreen: LiveData&lt;Event&lt;Post&gt;&gt;
          get() = _goToDetailScreen
  
      private val _postViewState =
          savedStateHandle.getLiveData&lt;ViewState&lt;List&lt;Post&gt;&gt;&gt;(POST_LIST)
  //        MutableLiveData&lt;ViewState&lt;List&lt;Post&gt;&gt;&gt;()
  
      override val postViewState: LiveData&lt;ViewState&lt;List&lt;Post&gt;&gt;&gt;
          get() = _postViewState
  
      override fun getPosts() {
  
          getPostsUseCase.getPostFlowOfflineFirst()
              .convertToFlowViewState()
              .onStart {
                  _postViewState.value = ViewState(status = Status.LOADING)
              }
              .onEach {
                  _postViewState.value = it
              }
              .launchIn(coroutineScope)
      }
  
      override fun refreshPosts() {
          getPostsUseCase.getPostFlowOfflineLast()
              .convertToFlowViewState()
              .onStart {
                  _postViewState.value = ViewState(status = Status.LOADING)
              }
              .onEach {
                  _postViewState.value = it
              }
              .launchIn(coroutineScope)
      }
  
      override fun onClick(post: Post) {
          _goToDetailScreen.value = Event(post)
      }
  }
  </code></pre>
  <p>And the test being</p>
  <pre><code>@Test
  fun `given exception returned from useCase, should have ViewState ERROR offlineFirst`() =
      testCoroutineRule.runBlockingTest {
  
          // GIVEN
          every {
              savedStateHandle.getLiveData&lt;ViewState&lt;List&lt;Post&gt;&gt;&gt;(AbstractPostListVM.POST_LIST)
          } returns MutableLiveData()
  
          every {
              savedStateHandle.getLiveData&lt;Event&lt;Post&gt;&gt;(AbstractPostListVM.POST_DETAIL)
          } returns MutableLiveData()
  
          every {
              useCase.getPostFlowOfflineFirst()
          } returns flow&lt;List&lt;Post&gt;&gt; {
              emit(throw Exception(&quot;Network Exception&quot;))
          }
  
          val testObserver = viewModel.postViewState.test()
  
          // WHEN
          viewModel.getPosts()
  
          // THEN
          testObserver
              .assertValue { states -&gt;
                  (states[0].status == Status.LOADING &amp;&amp;
                          states[1].status == Status.ERROR)
              }
              .dispose()
  
          val finalState = testObserver.values()[1]
          Truth.assertThat(finalState.error?.message).isEqualTo(&quot;Network Exception&quot;)
          Truth.assertThat(finalState.error).isInstanceOf(Exception::class.java)
          verify(atMost = 1) { useCase.getPostFlowOfflineFirst() }
      }
  </code></pre>
  <p>This test works when i use <code>MutableLiveData</code> instead of <code>SavedStateHandle.getLiveData()</code> with this and other tests.</p>
  <p>With savedStateHandle being mocked as</p>
  <p><code>private val savedStateHandle: SavedStateHandle = mockk()</code></p>
  <p>returns</p>
  <pre><code>io.mockk.MockKException: no answer found for: SavedStateHandle(#2).getLiveData(POST_LIST)
  </code></pre>
  <p>and i changed mocked savedStateHandle to with <code>relaxed = true</code></p>
  <pre><code>private val savedStateHandle: SavedStateHandle = mockk(relaxed = true)
  </code></pre>
  <p>based on this <a href="https://stackoverflow.com/questions/61151905/io-mockk-mockkexception-no-answer-found-for-savedstatehandle1-setkey-some">question</a>.</p>
  <p>Now value of postViewState does not change and test fails with</p>
  <pre><code>java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
  </code></pre>
  <p>What is the correct way to mock and get LiveData with <code>SavedStateHandle</code>?</p>