25 + 5 clock clock tests failing

Hi all.
Hope you’re all doing well :slight_smile:
I need some direction with my 25 + 5 clock project.
I get 15/29 tests to pass.

To me it looks like it runs , and that the timer goes down in a session , then to break , the timer goes down again , and then back to session etc.

These fail:
8. I can see an element with corresponding id=“time-left”. NOTE: Paused or running, the value in this field should always be displayed in mm:ss format (i.e. 25:00).
timer:

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.

6. I should not be able to set a session or break length to <= 0.

7. I should not be able to set a session or break length to > 60.

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

Timeout of 4000ms exceeded. For async tests and hooks, ensure “done()” is called

11. If the timer is paused and I click the element with id=“start_stop”, the countdown should resume running from the point at which it was paused. 25 + 5 clock 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.

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

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

Timer has not reached 00:00.

And off course the audio errors but i haven’t added sound yet.
I tried adding done() but I get done() is not defined errors.
I can see my timer running , so I’m very unsure at this point.
Am I on the right track at least ?

Here’s my codepen:
codepen

thanks!

Using window.done() I managed to pass tests 10 and 11, but the rest still fail.

Okay, I was very tired yesterday when I posted and it was very late :stuck_out_tongue:
at this point, tests 12, 14, 15 and (obviously) the audio fail.

I probably can figure this out by myself at this point.
I will update if not :slight_smile:
Thanks

Hey @agate!

Wish I could help but I haven’t started this project yet.

It looks like you are almost there though.

Good luck!

2 Likes

Thanks for the reply and encouragement JWilkins :grinning:

unfortunately I’m stuck again. I jumped too soon. :stuck_out_tongue:

18out of 29 pass. Sound tests failing aside, can someone help ? Some insight? As it also complains the clock is not running ,while I can clearly see it is.

The test feedback:

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

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

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’

11. If the timer is paused and I click the element with id=“start_stop”, the countdown should resume running from the point at which it was paused.

25 + 5 clock has started but time displayed is not changing: expected ‘00’ to not equal ‘00’ AssertionError: 25 + 5 clock 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.

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

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

Timer has not reached 00:00.

Hoping for some insight. To me it looks to run normally, it’s hard to know how to proceed .

Thanks

I could still use some help here. More tests are passing, but it doesn’t seem to be stoppable after the tests have run. Whereas if I run it myself it pauses and stops just fine.
Hope someone is willing to take a look :slight_smile:
Thanks

edit: I made some changes so it does stop now after the test . The test mentions using done() ? From reading online I can see that this is used as a callback, but I’m unsure where to add it. I would guess the playpause function, but I’m not sure how . So I went with async /await as that seems more straightforward, but it still complains and wants done().

Hope someone can take a look :slight_smile:

These tests still fail:

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’ AssertionError: Default timer label was not properly reset .

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

25 + 5 clock has paused but time continued elapsing: expected ‘56’ to equal ‘59’

11. If the timer is paused and I click the element with id=“start_stop”, the countdown should resume running from the point at which it was paused.

25 + 5 clock has paused but time continued elapsing: expected ‘57’ to equal ‘59’

And off course the audio, as I haven’t added that yet.
Any insights ?

this may as well be deleted as nobody replies anyway. I’m still stuck and on my own it seems.

Weekends are usually slower. The best times to post questions are on weekdays especially in the mornings. Did you still want to delete this post?

1 Like

I’m sorry you have not gotten help yet… I can’t help you either, as I have not yet been able to reach this part of the curriculum.

I have to agree with the tests tho, if I press the start button the timer doesn’t start

1 Like

I have not tried completing this project so I can’t help you yet. (It’s impossible!) :sweat_smile:

1 Like

I’m getting sooo frustrated with this one ! :rage:

I got it to work in the beginning to run /pause and all that, but the tests were failing , so… I looked online, found this:

This has been helpful , from what I read it keeps track of the time in between a pause/resume , so the timer is accurate.
But now it won’t pause.

Hope someone can take a look.
codepen again

thanks :slight_smile:

One thing that might help is to look through previous posts from people who have struggled with this same project. Good news is that you are not alone. You might find some answers in their previous posts.
https://forum.freecodecamp.org/search?q=25%20%2B%205%20clock

1 Like

I’m still stuck . I can’t figure out how to play/pause with my current setup.
I had it working before , but now it’s not at all, it 'll run , but pausing isn’t working. :frowning: I know I’m not calling pause, because that part is tricky. I should call it from playpause() but when/where. On pause toggle seems most obvious , but if I toggle paused in playpause() that won’t work either.

That is some switch you got inside that reducer. Are you sure there isn’t some code duplication going on?

I should preface this by saying, I’m really not much of a Redux guy. But it looks like you are mutating the initial state object.

  1. As far as I know, when copying the initial state object to state in the reducer it’s a shallow copy.

  2. You seem to be using the initial state as default values but you are mutating it (it does not remain the same as it was starting out).

You should be copying the initial state into the reducer and not mutate it. Use copies of state and copies of nested state inside the reducer. Return or copy pure values, do not copy mutated values.

For example, this is a mutation.

defaultBreak: --defaultState.defaultBreak

It doesn’t matter that you copy the result of the mutation into a copy, you have already mutated the initial object (and AFAIK the shallow copy).

This on the other hand simply copies the value and does not mutate the object.

defaultBreak: state.defaultBreak - 1


Anyway, I honestly didn’t really look at or test the code much.

I would suggest you install the Redux dev tools in the browser and check that everything is working as expected. For example. After the timer has reached the break part of the countdown try resetting it. Does the state match what you expect?

I would also go over the tutorials from the Redux docs.

oh oke thanks. I’ll make those changes. It makes sense actually , even though it seems the same . It was something I overlooked.

it’s a complete mess. I tried to change it like you said , and it’s a mess.
I’ll just be done at this point. I’m burned up.
I’m not redoing this all. very dissapointed as I felt I was doing okay :frowning:

Sorry to hear that.

I know it’s not much consolation right now but struggling is good, in fact, it’s great. You learn so much from it because it forces you to really dig in and get your hands dirty. I know passing the tests and having a working project seems like the ultimate goal here, but it’s really not. The ultimate goal is learning. Struggling and failing, but learning a bunch in the process is worth 100 times more than breezing through something and not learning anything.


May I suggest you maybe try without Redux first?

Or make sure you have gone through enough of the docs and tutorials Redux provides to where you feel more comfortable with it. Redux adds a fair bit of complexity.

I would also suggest you check out the latest methodology of using Redux Toolkit.

Edit: you can also check out Easy Peasy for state management. I haven’t used it much but a lot of people like it and it simplifies things.

2 Likes

Hey @agate!

I know that this project is tough and lots of people struggle with this project. I am about to start the front end projects myself and I am sure I will be experiencing the same issues.

I understand what it is like to want to give up. I started CS50 a few months back and was moving along and solving the problem sets with a few struggles here and there. But then I got to week 4 with pointers and memory and struggled alot with trying to finish the problem sets. I actually took time off from the class because I was so frustrated. But I did end up going back and finally solving it.

So maybe you need to just take a break away from this project for a few days and maybe checkout the resources that @lasjorg mentioned. Then you can revisit this with fresh eyes and I am sure that you will get it.

Good luck!

2 Likes