Skip to content

Commit 937792d

Browse files
committed
include value in message
1 parent 1ff7edd commit 937792d

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/createStore.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,9 +284,9 @@ export function createStore<
284284

285285
if (typeof action.type !== 'string') {
286286
throw new Error(
287-
`Action "type" property must be a string. Instead, the actual type was: ${kindOf(
287+
`Action "type" property must be a string. Instead, the actual type was: '${kindOf(
288288
action.type
289-
)}.`
289+
)}'. Value was: '${action.type}' (stringified)`
290290
)
291291
}
292292

test/createStore.spec.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -575,16 +575,15 @@ describe('createStore', () => {
575575

576576
it('throws if action type is not string', () => {
577577
const store = createStore(reducers.todos)
578-
const expectedErr = /Action "type" property must be a string/
579578
expect(() =>
580579
store.dispatch({ type: false } as unknown as AnyAction)
581-
).toThrow(expectedErr)
580+
).toThrow(/the actual type was: 'boolean'.*Value was: 'false'/)
582581
expect(() => store.dispatch({ type: 0 } as unknown as AnyAction)).toThrow(
583-
expectedErr
582+
/the actual type was: 'number'.*Value was: '0'/
584583
)
585584
expect(() =>
586585
store.dispatch({ type: null } as unknown as AnyAction)
587-
).toThrow(expectedErr)
586+
).toThrow(/the actual type was: 'null'.*Value was: 'null'/)
588587

589588
expect(() =>
590589
store.dispatch({ type: '' } as unknown as AnyAction)

0 commit comments

Comments
 (0)