This community-built FAQ covers the “Introduction” exercise from the lesson “Learn TDD With Mocha”.
Paths and Courses
This exercise can be found in the following Codecademy content:
Web Development
Learn JavaScript Unit Testing
FAQs on the exercise Introduction
There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply () below.
If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.
Join the Discussion. Help a fellow learner on their journey.
Ask or answer a question about this exercise by clicking reply () below!
Agree with a comment or answer? Like () to up-vote the contribution!
Need broader help or resources? Head here.
Looking for motivation to keep learning? Join our wider discussions.
Learn more about how to use this guide.
Found a bug? Report it!
Have a question about your account or billing? Reach out to our customer support team!
None of the above? Find out where to ask other questions here!
Shouldn’t the test fail when there is nothing in the it
block?
Just popping in to say that this was a nice module! The TDD methodology was well-explained and the exercises were well crafted
The test fails immediately for me. I know someone else mentioned it should fail without something in the it block, I’m assuming it didn’t fail for them. My problem is knowing even what to do since there’s no code to even look at to generate the test for. My brain is also a little fried. Some guidance would be helpful.
Edit: Nevermind. Figured it out. There is a solution, just be sure to read the test output.
1 Like
im learning TDD with mocha and i cant scroll my terminal upwards to view contents. whats the problem
In the Rooster Regulation project, I was receiving this error when I was trying to use the assert.throw
functionality to test if a function throws an error if a wrong number is passed in as an argument:
TypeError: expected.call is not a function
Upon my research, I realized that this error is usually thrown when the node version is relatively old. Hence, I write this post to inform @codecademy of this issue and to solve it.
const assert = require("assert");
const Rooster = require("../index.js");
//FOR TIME-AT-DAWN - HOUR PASSED < 0
describe("timeAtDawnLesserThanZero", () => {
it("throws an error if passed a number less than 0", () => {
//SetUp
const expectedResult = new RangeError("Number cannot be lesser then 0");
//Exercises and Verifies
assert.throws(() => {
Rooster.timeAtDawn(-1);
}, expectedResult);
//Tears Down - Not Needed Here!
});
});