My pomodoro clock seems to be working but fails tests

Anyone know what’s going on?

Here is the link to my code:

Test one is failing:

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.

The error given is:
Timer has not reached 00:00.

Test nine and ten also failing:

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).

10. If the timer is running and I click the element with id=“start_stop”, the countdown should pause.

l.exec(…) is null

Ok, so I figured out that to pass test one, the time needs to be in the 00:00 format and not the 0:00 format. I’ts a pity. The trailing zero is unnecessary in my opinion. Still trying to figure out the other ones.

Several tests are starting and stopping your timer, but your timer isn’t resilient to this, so you’re getting some unintended behavior.

To see what I mean replicate the following in your environment:

  • Refresh your webpage so you have a clean start. Then run the tests multiple times —without refreshing your page again— and pay close attention to the session countdown and the number of tests passing each time you run it.

  • Refresh your webpage so you have a clean start. Then rapidly click the start/stop button 6-12 times in a row. Again, play close attention to the session countdown.

1 Like

Thanks for your reply. I see the bug now. Would the solution be to use I’m not really sure what causes this bug.

1 Like

Fixed it. The fix for the bug was to make sure the setInterval was cleared on starting and stopping the timer. Tests still didn’t pass after that but it turns out my timer was running on a one second delay. This one had me pretty frustrated.