mardi 25 février 2020

For loop pure function jest test using expect... cannot read property

I am trying to make a pure function using a for loop pass a jest test/npm test in the terminal... I am getting an error that it cannot read the property of toBe...

My function:

const syntax = {
   for1: (a,b) => {
      for(let a=1; a<10; a++){
         for(let b=1; b<10; b++){
             return a+b;
         }
      }
   }
}

My Test.js file: I want it to test that 1+2 does not equal 0 making this test passing for the function

test('FORLOOP', () => {
    expect(syntax.for1(1,2).not.toBe(0));
});

TypeError in terminal:

TypeError: Cannot read property 'toBe' of undefined
      45 | test('FORLOOP', () => {
    > 46 |     expect(syntax.for1(1+3).not.toBe(0));
         |            ^
      47 | });

Aucun commentaire:

Enregistrer un commentaire