25 + 5 project . several tests still not passing

Hi all.
:slight_smile:
I deleted this as it was irrelevant and might confuse people.

My question is the last post .

Thanks

From your code:

defaultBreak : ++defaultState.defaultBreak, //should be  defaultBreak : defaultState.defaultBreak - 1  , but it breaks

It should be

defaultBreak : state.defaultBreak + 1

You are still using the initial state object, leave it alone. Use the state inside the reducer.

You are still mutating state in a lot of places. This is one of the hard parts of Redux, learning how to avoid state mutation. Again, my advice is to take some more time to learn Redux. Do some simple tutorials, then make some simple projects where you use Redux. After you have learned more about Redux, re-apply what you have learned to this project.

The way I see it, you are not making a 25 + 5 clock, you are learning about React and Redux. So focus on learning.

1 Like

oh oke , I not do defaultState but state. Iā€™ll try that.

Look you canā€™t brute force this. You are going to have to spend more time learning about Redux, there is just no way around it.

Remember itā€™s just a tool. Some people hate Redux but they have to work with it because the project (their work) requires it. This project does absolutely not require Redux, so if you do want to use Redux, you are just going to have to learn more about it first.


Edit: BTW, I donā€™t mean you shouldnā€™t use this thread to ask for help, you totally should (please do). But it will be much better after you spend a little more time learning about the tools you are using.

1 Like

I will, any particular tutorial that would be helpful for not changing state ?:slight_smile: I off course read/did FCC tutorials, some youtube tutorials,etc, but itā€™s probably limited.

I donā€™t particularly like the redux/react.org site.

Well, the Redux site is the official docs so you canā€™t really get closer to the source than that. I would suggest you read through the writing-reducers part at least. If you have not checked out the site lately it has been updated and is better than it used to be.

Dan Abramov has some free videos on egghead.io that gives a good introduction.

Programming with Mosh has a fairly comprehensive video on Redux which touches on some important concepts.

Again, you do not have to use Redux for this project.

If I was to ask you to write this app in just React do you think you would be able to do it? Do you understand normal state management in React well enough? Because if not, throwing Redux in the mix is not going to make it any easier.


Just as an aside, and not to pile more wood on the fire, but just as a friendly FYI.

I would suggest using a coding environment that is better geared to React and Redux. Check out CodeSandbox itā€™s so much better for this kind of work and a lot more like working locally inside a real code editor. It has much better error handling and the starter React template is based on create-react-app.

Personally, I really do not like Codepen for React and I have seen it swallow errors that should result in the code failing to compile, the error handling/feedback is just very lacking on Codepen.

1 Like

Thanks , I will look into codesandbox as well :slight_smile:

Hi all.
So, Iā€™ve made some changes to my code, but itā€™s still not passing all tests.
These are the errors Iā€™m getting:

1. When I click the element with the id of ā€œresetā€, any running timer should be stopped, the value within id=ā€œbreak-lengthā€ should return to 5, the value within id=ā€œsession-lengthā€ should return to 25, and the element with id=ā€œtime-leftā€ should reset to itā€™s default state.

Timer has not reached 00:00.

12. When a session countdown reaches zero (NOTE: timer MUST reach 00:00), and a new countdown begins, the element with the id of ā€œtimer-labelā€ should display a string indicating a break has begun.

Timer has not reached 00:00.

14. When a break countdown reaches zero (NOTE: timer MUST reach 00:00), and a new countdown begins, the element with the id of ā€œtimer-labelā€ should display a string indicating a session has begun.

Timer has not reached 00:00

Iā€™ve also noticed that it takes forever to run the tests, and that there are several red times marked. I donā€™t know if that is a problem or not, or maybe itā€™s because of these errors Iā€™m getting?

Ignoring the audio right now as Iā€™m not done with that yet.

codepen

iā€™d just like to know if Iā€™m on the right track, some hints or so
Thanks :slight_smile:

  1. You do not want to overwrite the state, just return a new copy.

  2. I would suggest you use the more common syntax of returning the state object with the old state spread in and whatever updates are needed.

  3. Move the if logic out of the reducer into handler functions so the dispatch is only called if the condition is met.

case INCBREAK:
  return {
    ...state,
    defaultBreak: state.defaultBreak + 1
  }
handleBreakIncrement = () => {  
  if(this.props.clock.defaultBreak < 60) {
    this.props.breakIncrement()
  }
}
onClick={this.handleBreakDecrement}
1 Like

Thanks, those changes make total sense.
I did see it done somewhere state = object.assign() etc and then state was returned, but it does technically still overwrite state as itā€™s assigning to state. thanks :slight_smile:

I now only have more errors.

1. When I click the element with the id of ā€œresetā€, any running timer should be stopped, the value within id=ā€œbreak-lengthā€ should return to 5, the value within id=ā€œsession-lengthā€ should return to 25, and the element with id=ā€œtime-leftā€ should reset to itā€™s default state.

Timer has not reached 00:00. ā€˜Session\n25:00\nstart/pauseresetā€™

10. If the timer is running and I click the element with id=ā€œstart_stopā€, the countdown should pause.

25 + 5 has started but time displayed is not changing: expected ā€˜00ā€™ to not equal ā€˜00ā€™

12. When a session countdown reaches zero (NOTE: timer MUST reach 00:00), and a new countdown begins, the element with the id of ā€œtimer-labelā€ should display a string indicating a break has begun.

Timer has not reached 00:00.

14. When a break countdown reaches zero (NOTE: timer MUST reach 00:00), and a new countdown begins, the element with the id of ā€œtimer-labelā€ should display a string indicating a session has begun.

Timer has not reached 00:00.

None of these errors are making sense when I test the timer it seems to work correctly. Iā€™m at a loss once again. Itā€™s very hard to know how to fix it if donā€™t even see the errors.
Hope someone is willing to help , yet again ! :slight_smile:

itā€™s almost as if thereā€™s two timers running and thatā€™s causing a problem, but iā€™m sure thereā€™s only one timerId set and cleared.
Iā€™m hoping the problem is very minor at this point, and I can finish this project soon. Thanks :slight_smile:

Iā€™m at a loss still whatā€™s causing the tests to fail.
Hope someone has some insight , just a clue with be very helpful :slight_smile:

These are the errors now.

1. When I click the element with the id of ā€œresetā€, any running timer should be stopped, the value within id=ā€œbreak-lengthā€ should return to 5, the value within id=ā€œsession-lengthā€ should return to 25, and the element with id=ā€œtime-leftā€ should reset to itā€™s default state.

Default timer label was not properly reset : expected ā€˜Break\n25:00\nstart/pauseresetā€™ to equal ā€˜Session\n25:00\nstart/pauseresetā€™

9. If the timer is running, the element with the id of ā€œtime-leftā€ should display the remaining time in mm:ss format (decrementing by a value of 1 and updating the display every 1000ms).

25 + 5 clock has started but time displayed is not changing : expected 0 to be above 0 AssertionError: 25 + 5 clock has started but time displayed is not changing : expected 0 to be above 0

10. If the timer is running and I click the element with id=ā€œstart_stopā€, the countdown should pause.

25 + 5 has started but time displayed is not changing: expected ā€˜00ā€™ to not equal ā€˜00ā€™ AssertionError: 25 + 5 has started but time displayed is not changing: expected ā€˜00ā€™ to not equal ā€˜00ā€™

12. When a session countdown reaches zero (NOTE: timer MUST reach 00:00), and a new countdown begins, the element with the id of ā€œtimer-labelā€ should display a string indicating a break has begun.

Timer has not reached 00:00. Error: Timer has not reached 00:00.

13. When a session countdown reaches zero (NOTE: timer MUST reach 00:00), a new break countdown should begin, counting down from the value currently displayed in the id=ā€œbreak-lengthā€ element.

Timer has switched to Break time, but it didnā€™t start with the correct value.: expected 1 to equal 5

14. When a break countdown reaches zero (NOTE: timer MUST reach 00:00), and a new countdown begins, the element with the id of ā€œtimer-labelā€ should display a string indicating a session has begun.

Timer has not reached 00:00.

It just doesnā€™t make sense the timer runs, the timer changes correctly , from what I see between sessions/breaks?
I just hate to waste so much time on this. Iā€™m hoping someone is willing to take a look.

I know itā€™s more errors than before, but I made changes that logically to me make sense, as there are anyway still errors either way , I leave the changes.
Thanks