question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Actions without types throw an error rather than return the default state

See original GitHub issue

In my test setup code I have this line:

test.beforeEach(t => {
  const initialState = reducer();
});

where

const reducer = handleActions({ ... }, { /*initial state*/});

However, the first method throws an error because: screen shot 2016-10-06 at 11 15 55 am

and in the transpiled source it looks like action.type.toString() is called unguardedly. Now, maybe I’m misunderstanding how FSAs work, but I think it makes sense for a reducer test to be able to check that the initial state is returned when the action type is missing. I can try to make a PR for this as well, if you think I’m correct about the expected behaviour.

If not, could you please fill me in on what I’m missing? Thanks!

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
JaKXzcommented, Oct 6, 2016

Sorry for the duplication/noise, and 🙏 for a great project! I thought I’d searched the issues properly but I guess not.

0reactions
JaKXzcommented, Oct 6, 2016

Yeah at this point it’s just 🚴🏚-ing about test setup code, I can’t imagine a real example of having an undefined action or action type being dispatched. And I think I understand the argument that having the “robustness” to handle that is more bad than good.

Read more comments on GitHub >

github_iconTop Results From Across the Web

useReducer's initialState is typed as never? - Stack Overflow
I will attempt crudely to illustrate below. Error: passing default value as IObject here ↓ const reducer = (state: IObjectState, action: ...
Read more >
Error, IfError, IsError, and IsBlankOrError functions in Power ...
Reference information including syntax and examples for the Error, IfError, IsError, IsBlankOrError functions in Power Apps.
Read more >
Control flow and error handling - JavaScript - MDN Web Docs
Exception types ​​ Just about any object can be thrown in JavaScript. Nevertheless, not all thrown objects are created equal. While it is...
Read more >
10 Handling PL/SQL Errors
A SELECT INTO statement returns no rows, or your program references a deleted element in a nested table or an uninitialized element in...
Read more >
createReducer - Redux Toolkit
defaultCaseReducer A "default case" reducer that is executed if no case reducer and no matcher reducer was executed for this action. Returns​.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found