Clock 25-5 Test Problem

Hi!
So I have no idea why i can’t pass those tests. Practically application does what it supposed to do and I double checked code but i must’ve missed something.

Github Page embedded with tests- Pomodoro Timer
Github Code - GitHub - M4rt1/pomodoro-app: Pomodoro Timer with ReactJS

Something I noticed - when you click “start/stop” → “reset”, you have to click “start/stop” twice to make the timer run again.

I’m pretty sure you have a timing synchronization problem. A number of tests indicate the timer has not reached 00:00. This means that the display of 00:00 did not stay for 1 second. In your Timer component’s decreaseTimer function, the default case is

this.setState((prevState) => {
                    return {
                        timerSecond: prevState.timerSecond - 1
                    }
                })

and this won’t get called for another second. So that time remains on the display for 1 second. But when the timer gets to 0, you did

 this.props.decreaseTimerMinute();
                this.setState({
                    timerSecond: 59
                })

in the switch case 0. You are resetting the timer immediately, so the display of 0 won’t stay on the display for 1 second. We discussed this issue in another thread (look for 25+5 Clock - Help) If you solve this timing problem, I believe many of the test failures will go away.

Another suggestion I would like to make is the way of tracking the time left. It seems like you’re keeping track of minutes in App and seconds in Timer. I think it will simplify a lot if you let Timer keep track of remaining time. Keep track of time remaining in seconds and convert that to min:sec when displaying it.

BTW, I like your visual. The page is very attractive.

Thanks!
By fixing that i managed to pass more test :grinning:

Thanks!
Yeah, so problem was that the timer when changing from session to break or vice versa was setting {minute} to {source minute -1} and 59 second. By fixing that i managed to pass rest of the tests :grinning:

Good. Glad to hear that. That timing thing is hard to detect because you actually can see 00:00 appear. FCC is running good tests, although it was frustrating and perplexing when you first saw that error.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.