Pomodoro Clock: tests fail: Timer has not reached 00:00

Pomodoro Clock: tests fail: Timer has not reached 00:00
0

Tell us what’s happening:
It’s failing the tests that check for time running all the way down to 00:00

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

Visually you can see the time running down to 00:00, so it’s hard for me to understand why the tests fail.
To save some time getting a visual confirmation, use the 5 second button in the debug panel.
You can see for yourself at the codepen link below.

The display string is formatted so:

`${minutes < 10 ? '0' : ''}${minutes}:${remainderSeconds < 10 ? '0' : ''}${remainderSeconds}`

so there is no extraneous whitespace to mess things up.

If you have any ideas I would greatly appreciate your feedback.

Thanks!

Your code so far
Pomodoro Clock (codepen)

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/front-end-libraries/front-end-libraries-projects/build-a-pomodoro-clock

1 Like

Is this test 17, the first one in the timer section? I’m also failing at this same portion. The description have 6 sub-tests. Mine will mechanically work as described in the user stories, and fails anyway.

If I figure it out, I’ll send a solution.

Thanks Mark, I’ll do the same. My fails everytime it tests for 00:00. But I can see that it counts down to 00:00 and it remains there for the full second until switching modes.

Very perplexing.

1 Like

Same. I’m looking into if the string “00:00” is failing, because it has to be officially formatted into mm:ss.

1 Like

I’ve met the same error today, then I figure out it’s not about dispaly format. I pass the test after changing the inaccurate setInterval() to recursive setTimeout(), like this:

const interval = () => {
  setTimeout(interval, 1000);
  timerRuning();
};
setTimeout(interval, 1000);

I guess the test missed the ‘00:00’ moment due to an inaccurate timer. Maybe you can try this solution

2 Likes

Hi Mark, did you resolve this? I found that their test code isn’t quite right. If you are using the setInterval interval as your time basis then it should pass the tests. On the other hand, using the system clock as your time basis (and monitoring that using setInterval) causes it to fail. This is a problem because setInterval as a time basis is not a good way to time things. I’ve written it up as an issue. Curious to see their response.

I have not. I was going to make a ticket as well, but I’ll add on to yours with a screenshot of my app at 00:00. Mine is built in react-redux. I’ve decided to build a simpler version with just react, and I’ll see if I can make it work that way. Unfortunately, I think it’s the test. I’ll be on the road so it may take a couple of days. Thanks for being diligent. It’s annoying to make it this far, and to hit a road block that may be out of my control.

In my case at least it is due to the the test assuming you are using setInterval or setTimeout as your basic timer. I instead am using the system clock (i.e. Date) and polling that using setInterval.

Here’s the problem, the test hijacks both setTimer and setTimeout and clocks them at 30msec so that the tests run in a reasonanble length of time. It then uses your UI to set the lengths of break and session to 1 minute. Then it starts your pomodoro and expects to see 00:00 in less than 5 seconds. At 30msec/1sec this would work. This doesn’t work in my case. It just causes my software to poll the system clock more often but the system clock of course is not affected. So at the end of 5 seconds it sees the display at 00:55 and fails.

I wrote up an issue on freecodecamp github and I see that ValeraS has made a pull request, so it should be fixed in however much time it takes for them to complete the process, I guess they take their time to make sure the change is done properly.

1 Like

Same thing happened to me :sweat: I’d been wondering how they did the tests if I used Date to countdown.

I noticed the test appears to have been fixed.

Tom,

Thanks for all your work on this. My test passed on 00:00 now too. I have to fix a couple of other things, but essentially the main issue is finished.

Thanks again,

Mark

No I dont think so they have fixed this issue as I am able to see my clock at 00:00 when run manually but during the test suite I’m failing the test again and again.please help !!

1 Like

Sometimes the error code shows “00:00” when it’s something else. It will say something like, “5 should equal 1,” and it means it should do that at the zeroes.

Same problem with me if anyone can help…

Any solutions to this?

Hi !
I’m facing the same issue and didn’t find the solution
You can see my tests here https://codepen.io/kanohapierre/full/NoBVvg

I was having this problem too. My tests passes all of a sudden after I created a >>this.state.timer<< property that holds the default 25:00 string. In detail, my callback function inside the setInterval method decrements the >>this.state.minutes<< and >>this.state.seconds<< property accordingly. Then I call another of my created methods, the >>this.createTime(this.state.minutes-1, 59)<< or alternatively the this.createTime(this.state.minutes, this.state.seconds-1). Thus the this.createTime method concatenates the this.state.minutes and this.state.seconds together into my this.state.timer property which is passed and {shown} in the child component.

I did not use a Date object. I felt this approach was extra. I avoided the ternary ()?return:return option.

When I first started, I didn’t have a this.state.timer property. I just used a this.state.minutes and this.state.seconds and passed it to the rendering child component to be altered with a ternary operation. I’m not sure why it didn’t work at first. Maybe when I clicked pause the state wasn’t fully set yet and the tests didn’t see what it expected. But with a createTime function, I made sure to update the timer string to reflect the very moment we’ve reached a new 1000ms interval.

I guess you can also say I solved the problem by refactoring and trying again.

Thanks! How do you pause the interval?

Hey guys… just in case someone makes the same mistake… in my case the problem was that when the remaining time was 0 seconds, I would display it as 0:00, not 00:00… I had only added padding to the seconds portion of the timer.

2 Likes

I am also dealing with this issue. I tried pretty much everything and the result remains the same: timer works well in the browser, but in testing suite it has a glitch and transition is being initiated sooner than it is supposed to.
my code has another setTimeout which works just fine, so I at least know that environment can handle it