jeudi 30 juin 2016

Why doesn't my before() hook in Mocha run at all?

I have written this following code in a file named "example.js":

console.log('HI HI HI HI');

describe('hooks', function() {
  console.log('before before');
  before(function() {
    console.log('ok');
  });
  console.log('after before');  
})

Output of the code when i run "mocha example.js" is:

HI HI HI HI
before before
after before
  0 passing (1ms)

Why didn't the "ok" get printed? I thought the before() hook runs before all the code in the describe() block?

Aucun commentaire:

Enregistrer un commentaire