Skip to content
Discussion options

You must be logged in to vote

There might be a couple things going on, but right off the bat I think one problem is that the .dependencies extension on reducers is not the right tool to set up dependencies in tests, because it's immediately going to be overridden by the default test dependencies (edit: see below answer). It is for modifying dependencies in the reducer tree from parent to child in application code.

Instead, I think you want to do something like this:

@MainActor
final class DateMockingTests: XCTestCase {
  func test_changingDateOnRuntime() async {

    let store = TestStore(
      initialState: DateReducer.State(displayDate: ""),
      reducer: { DateReducer() },
      withDependencies: { $0.date.now = D…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@mbrandonw
Comment options

@bdolewski-intellias
Comment options

Answer selected by bdolewski-intellias
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants