@@ -115,38 +115,42 @@ public struct _DebugReducer<Base: ReducerProtocol, DebugState, DebugAction>: Red
115115 self . logger = logger
116116 }
117117
118+ @usableFromInline
119+ @Dependency ( \. context) var context
120+
118121 @inlinable
119122 public func reduce(
120123 into state: inout Base . State , action: Base . Action
121124 ) -> Effect < Base . Action , Never > {
122125 #if DEBUG
123- let previousState = self . toDebugState ( state)
124- let effects = self . base. reduce ( into: & state, action: action)
125- guard let debugAction = self . toDebugAction ( action) else { return effects }
126- let nextState = self . toDebugState ( state)
127- return effects. merge (
128- with: . fireAndForget { [ actionFormat] in
129- var actionOutput = " "
130- if actionFormat == . prettyPrint {
131- customDump ( debugAction, to: & actionOutput, indent: 2 )
132- } else {
133- actionOutput. write ( debugCaseOutput ( debugAction) . indent ( by: 2 ) )
126+ if self . context != . test {
127+ let previousState = self . toDebugState ( state)
128+ let effects = self . base. reduce ( into: & state, action: action)
129+ guard let debugAction = self . toDebugAction ( action) else { return effects }
130+ let nextState = self . toDebugState ( state)
131+ return effects. merge (
132+ with: . fireAndForget { [ actionFormat] in
133+ var actionOutput = " "
134+ if actionFormat == . prettyPrint {
135+ customDump ( debugAction, to: & actionOutput, indent: 2 )
136+ } else {
137+ actionOutput. write ( debugCaseOutput ( debugAction) . indent ( by: 2 ) )
138+ }
139+ let stateOutput =
140+ DebugState . self == Void . self
141+ ? " "
142+ : diff ( previousState, nextState) . map { " \( $0) \n " } ?? " (No state changes) \n "
143+ await self . logger (
144+ """
145+ \( self . prefix. isEmpty ? " " : " \( self . prefix) : " ) received action:
146+ \( actionOutput)
147+ \( stateOutput)
148+ """
149+ )
134150 }
135- let stateOutput =
136- DebugState . self == Void . self
137- ? " "
138- : diff ( previousState, nextState) . map { " \( $0) \n " } ?? " (No state changes) \n "
139- await self . logger (
140- """
141- \( self . prefix. isEmpty ? " " : " \( self . prefix) : " ) received action:
142- \( actionOutput)
143- \( stateOutput)
144- """
145- )
146- }
147- )
148- #else
149- return self . base. reduce ( into: & state, action: action)
151+ )
152+ }
150153 #endif
154+ return self . base. reduce ( into: & state, action: action)
151155 }
152156}
0 commit comments