Factorial Feature - test is pending

Hi all

Can anyone advise why do I have a test pending and maybe how to fix it ? I double checked in the walktrhough video, I believe my code is correct…

``````index_text.js

var assert = require("assert");
var Calculate =  require('../index.js')

describe('Calculate', () => {
describe('.factorial', () => {
it('testing the output of 5! is equal to 120', () => {
//Setup
const inputNumber = 5;
const expectedResult = 120;

//Excercise
const result = Calculate.factorial(inputNumber);

//Verify
assert.equal(result, expectedResult)
});
it('testing the output of 3! is equal to 6', () => {
//Setup
const inputNumber = 3;
const expectedResult = 6;
//Excercise
const result  = Calculate.factorial(inputNumber);
//VERIFY
assert.equal(result, expectedResult)
});
it('testing the output of 0! is equal to 1'), () => {
//Setup
const inputNumber = 0;
const expectedResult = 1;
//Excercise
const result = Calculate.factorial(inputNumber)
//Verify
assert.equal(result, expectedResult);
}
});
});

index.js

const Calculate = {
factorial(inputNumber){
if(inputNumber === 0) {
return 1;
}
for(let i = inputNumber - 1; i >= 1; i--){
inputNumber *= i;
}
return inputNumber;
}
}

module.exports = Calculate;

``````

Calculate
.factorial
✓ testing the output of 5! is equal to 120
✓ testing the output of 3! is equal to 6
- testing the output of 0! is equal to 1

2 passing (6ms)
1 pending

\$

You’ve pointed out a huge clue about what’s going on by mentioning that it’s stuck in “pending” status instead of “failed” or “passing”.

What this means is that it found your call to `it()` that describes the test, but it wasn’t passed a function to execute for the test and/or there was never an assert. Double check your “pending” test with this in mind to see if you can find the issue.

Click for another hint

Look at the difference in these:

`````` // working
it('testing the output of 5! is equal to 120', () => {
it('testing the output of 3! is equal to 6', () => {

// not working
it('testing the output of 0! is equal to 1'), () => {
``````

Spot the difference?

Click for final hint if you need

The misplaced closing parenthesis is causing `it()` to be called without your arrow function as an argument, so it’s forever in “pending” status.

``````                                         // ---v
it('testing the output of 0! is equal to 1'), () => {
``````
1 Like

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.