Pomodoro clock tests mention 'done()', but what is it?

Pomodoro clock tests mention 'done()', but what is it?
0

#1

Tell us what’s happening:
I’ve noticed that the Pomodoro clock tests mention a ‘done()’ method that needs to be called for asynchronous tests and hooks but I’m not really sure what is meant by the done method? Is it a React thing?
Thanks in advance for your help.

#Pomodoro Clock tests passes: 15 failures: 14 duration: 30.32s 100.00% 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. Timeout of 5000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. Error: Timeout of 5000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. at s._timeoutError (https://cdnjs.cloudflare.com/ajax/libs/mocha/5.2.0/mocha.min.js:1:40654) at https://cdnjs.cloudflare.com/ajax/libs/mocha/5.2.0/mocha.min.js:1:38785 2. When I click the element with the id of "break-decrement", the value within id="break-length" decrements by a value of 1, and I can see the updated value. expected '5' to equal '1' AssertionError: expected '5' to equal '1' at o.c (https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js:205:1134) at o.e.(anonymous function) [as equal] (https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js:268:128) at Function.n.strictEqual (https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js:167:568) at r. (https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js:154:316734) at e (https://cdnjs.cloudflare.com/ajax/libs/mocha/5.2.0/mocha.min.js:1:39739) at s.run (https://cdnjs.cloudflare.com/ajax/libs/mocha/5.2.0/mocha.min.js:1:39675) at h.runTest (https://cdnjs.cloudflare.com/ajax/libs/mocha/5.2.0/mocha.min.js:1:45245) at https://cdnjs.cloudflare.com/ajax/libs/mocha/5.2.0/mocha.min.js:1:46107 at r (https://cdnjs.cloudflare.com/ajax/libs/mocha/5.2.0/mocha.min.js:1:44557) at https://cdnjs.cloudflare.com/ajax/libs/mocha/5.2.0/mocha.min.js:1:44626 3. When I click the element with the id of "break-increment", the value within id="break-length" increments by a value of 1, and I can see the updated value. expected '5' to equal '9' AssertionError: expected '5' to equal '9' at o.c (https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js:205:1134) at o.e.(anonymous function) [as equal] (https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js:268:128) at Function.n.strictEqual (https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js:167:568) at r. (https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js:154:317181) at e (https://cdnjs.cloudflare.com/ajax/libs/mocha/5.2.0/mocha.min.js:1:39739) at s.run (https://cdnjs.cloudflare.com/ajax/libs/mocha/5.2.0/mocha.min.js:1:39675) at h.runTest (https://cdnjs.cloudflare.com/ajax/libs/mocha/5.2.0/mocha.min.js:1:45245) at https://cdnjs.cloudflare.com/ajax/libs/mocha/5.2.0/mocha.min.js:1:46107 at r (https://cdnjs.cloudflare.com/ajax/libs/mocha/5.2.0/mocha.min.js:1:44557) at https://cdnjs.cloudflare.com/ajax/libs/mocha/5.2.0/mocha.min.js:1:44626 4. When I click the element with the id of "session-decrement", the value within id="session-length" decrements by a value of 1, and I can see the updated value. expected '25' to equal '21' AssertionError: expected '25' to equal '21' at o.c (https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js:205:1134) at o.e.(anonymous function) [as equal] (https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js:268:128) at Function.n.strictEqual (https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js:167:568) at r. (https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js:154:317632) at e (https://cdnjs.cloudflare.com/ajax/libs/mocha/5.2.0/mocha.min.js:1:39739) at s.run (https://cdnjs.cloudflare.com/ajax/libs/mocha/5.2.0/mocha.min.js:1:39675) at h.runTest (https://cdnjs.cloudflare.com/ajax/libs/mocha/5.2.0/mocha.min.js:1:45245) at https://cdnjs.cloudflare.com/ajax/libs/mocha/5.2.0/mocha.min.js:1:46107 at r (https://cdnjs.cloudflare.com/ajax/libs/mocha/5.2.0/mocha.min.js:1:44557) at https://cdnjs.cloudflare.com/ajax/libs/mocha/5.2.0/mocha.min.js:1:44626 5. When I click the element with the id of "session-increment", the value within id="session-length" increments by a value of 1, and I can see the updated value. expected '25' to equal '29' AssertionError: expected '25' to equal '29' at o.c (https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js:205:1134) at o.e.(anonymous function) [as equal] (https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js:268:128) at Function.n.strictEqual (https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js:167:568) at r. (https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js:154:318073) at e (https://cdnjs.cloudflare.com/ajax/libs/mocha/5.2.0/mocha.min.js:1:39739) at s.run (https://cdnjs.cloudflare.com/ajax/libs/mocha/5.2.0/mocha.min.js:1:39675) at h.runTest (https://cdnjs.cloudflare.com/ajax/libs/mocha/5.2.0/mocha.min.js:1:45245) at https://cdnjs.cloudflare.com/ajax/libs/mocha/5.2.0/mocha.min.js:1:46107 at r (https://cdnjs.cloudflare.com/ajax/libs/mocha/5.2.0/mocha.min.js:1:44557) at https://cdnjs.cloudflare.com/ajax/libs/mocha/5.2.0/mocha.min.js:1:44626 6. I should not be able to set a session or break length to <= 0. Value in element with id of "break-length" is less than 1.: expected '5' to equal '1' AssertionError: Value in element with id of "break-length" is less than 1.: expected '5' to equal '1' at o.c (https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js:205:1134) at o.e.(anonymous function) [as equal] (https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js:268:128) at Function.n.strictEqual (https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js:167:568) at r. (https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js:154:318412) at e (https://cdnjs.cloudflare.com/ajax/libs/mocha/5.2.0/mocha.min.js:1:39739) at s.run (https://cdnjs.cloudflare.com/ajax/libs/mocha/5.2.0/mocha.min.js:1:39675) at h.runTest (https://cdnjs.cloudflare.com/ajax/libs/mocha/5.2.0/mocha.min.js:1:45245) at https://cdnjs.cloudflare.com/ajax/libs/mocha/5.2.0/mocha.min.js:1:46107 at r (https://cdnjs.cloudflare.com/ajax/libs/mocha/5.2.0/mocha.min.js:1:44557) at https://cdnjs.cloudflare.com/ajax/libs/mocha/5.2.0/mocha.min.js:1:44626 7. I should not be able to set a session or break length to > 60. Value in element with id of "break-length" is greater than 60.: expected '5' to equal '60' AssertionError: Value in element with id of "break-length" is greater than 60.: expected '5' to equal '60' at o.c (https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js:205:1134) at o.e.(anonymous function) [as equal] (https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js:268:128) at Function.n.strictEqual (https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js:167:568) at r. (https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js:154:318901) at e (https://cdnjs.cloudflare.com/ajax/libs/mocha/5.2.0/mocha.min.js:1:39739) at s.run (https://cdnjs.cloudflare.com/ajax/libs/mocha/5.2.0/mocha.min.js:1:39675) at h.runTest (https://cdnjs.cloudflare.com/ajax/libs/mocha/5.2.0/mocha.min.js:1:45245) at https://cdnjs.cloudflare.com/ajax/libs/mocha/5.2.0/mocha.min.js:1:46107 at r (https://cdnjs.cloudflare.com/ajax/libs/mocha/5.2.0/mocha.min.js:1:44557) at https://cdnjs.cloudflare.com/ajax/libs/mocha/5.2.0/mocha.min.js:1:44626 8. When I first click the element with id="start_stop", the timer should begin running from the value currently displayed in id="session-length", even if the value has been incremented or decremented from the original value of 25. expected '05' to equal '25' AssertionError: expected '05' to equal '25' at o.c (https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js:205:1134) at o.e.(anonymous function) [as equal] (https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js:268:128) at Function.n.strictEqual (https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js:167:568) at r. (https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js:154:319549) at e (https://cdnjs.cloudflare.com/ajax/libs/mocha/5.2.0/mocha.min.js:1:39739) at s.run (https://cdnjs.cloudflare.com/ajax/libs/mocha/5.2.0/mocha.min.js:1:39675) at h.runTest (https://cdnjs.cloudflare.com/ajax/libs/mocha/5.2.0/mocha.min.js:1:45245) at https://cdnjs.cloudflare.com/ajax/libs/mocha/5.2.0/mocha.min.js:1:46107 at r (https://cdnjs.cloudflare.com/ajax/libs/mocha/5.2.0/mocha.min.js:1:44557) at https://cdnjs.cloudflare.com/ajax/libs/mocha/5.2.0/mocha.min.js:1:44626 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. duration: 64ms 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. duration: 96ms 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. Timeout of 5000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. Error: Timeout of 5000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. at s._timeoutError (https://cdnjs.cloudflare.com/ajax/libs/mocha/5.2.0/mocha.min.js:1:40654) at https://cdnjs.cloudflare.com/ajax/libs/mocha/5.2.0/mocha.min.js:1:38785 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. Timeout of 5000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. Error: Timeout of 5000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. at s._timeoutError (https://cdnjs.cloudflare.com/ajax/libs/mocha/5.2.0/mocha.min.js:1:40654) at https://cdnjs.cloudflare.com/ajax/libs/mocha/5.2.0/mocha.min.js:1:38785 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. Timeout of 5000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. Error: Timeout of 5000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. at s._timeoutError (https://cdnjs.cloudflare.com/ajax/libs/mocha/5.2.0/mocha.min.js:1:40654) at https://cdnjs.cloudflare.com/ajax/libs/mocha/5.2.0/mocha.min.js:1:38785 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. Timeout of 5000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. Error: Timeout of 5000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. at s._timeoutError (https://cdnjs.cloudflare.com/ajax/libs/mocha/5.2.0/mocha.min.js:1:40654) at https://cdnjs.cloudflare.com/ajax/libs/mocha/5.2.0/mocha.min.js:1:38785 #Audio 1. When a countdown reaches zero (NOTE: timer MUST reach 00:00), a sound indicating that time is up should play. This should utilize an HTML5 tag and have a corresponding id="beep". Timeout of 5000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. Error: Timeout of 5000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. at s._timeoutError (https://cdnjs.cloudflare.com/ajax/libs/mocha/5.2.0/mocha.min.js:1:40654) at https://cdnjs.cloudflare.com/ajax/libs/mocha/5.2.0/mocha.min.js:1:38785 2. The audio element with id="beep" must be 1 second or longer. 3. The audio element with id of "beep" must stop playing and be rewound to the beginning when the element with the id of "reset" is clicked. Audio element was not stopped when reset was clicked.: expected false to be true AssertionError: Audio element was not stopped when reset was clicked.: expected false to be true at o. (https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js:205:9102) at o.e (https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js:274:153) at Function.n.isTrue (https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js:167:997) at r. (https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js:154:326967) at e (https://cdnjs.cloudflare.com/ajax/libs/mocha/5.2.0/mocha.min.js:1:39739) at s.run (https://cdnjs.cloudflare.com/ajax/libs/mocha/5.2.0/mocha.min.js:1:39675) at h.runTest (https://cdnjs.cloudflare.com/ajax/libs/mocha/5.2.0/mocha.min.js:1:45245) at https://cdnjs.cloudflare.com/ajax/libs/mocha/5.2.0/mocha.min.js:1:46107 at r (https://cdnjs.cloudflare.com/ajax/libs/mocha/5.2.0/mocha.min.js:1:44557) at https://cdnjs.cloudflare.com/ajax/libs/mocha/5.2.0/mocha.min.js:1:44626

Your code so far

Your browser information:

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

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


#2

I don’t know in this particular test project, but usually done() is the callback for an async function. I suppose the tests are using that and, since they are failing, the callback is never triggered or something.

You can look into the code in the bundle.js and find the line where the test is failing to get a better understanding of what it wants to say.


#3

thanks for your help. I did end up trying to read the test suite (how painful! I’ve never seen such long lines of code before) and didn’t quite figure out what they meant by done() but I’ve moved on to something else.


#4

In tests written with Mocha (and maybe other testing frameworks, I don’t know), if you’re testing an asynchronous function, you pass done as a parameter to the test and then when all the asynchronous work your function needs is finished, you make your assertion and then call done to let Mocha know that your function’s async work is finished and it can now go on.

I’m pretty new to testing, but I think that’s accurate. Someone please correct me if I’m wrong!