Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

237
Visualizações
ReferenceError: expect is not defined when using jasmine to do a unit test

I am use jasmine to do a unit test when write a javascript lib, I follow the official doc https://jasmine.github.io/tutorials/your_first_suite, the code demo.js look like this:

'use strict';
    
describe("A suite", function() {
    it("contains spec with an expectation", function() {
      expect(true).toBe(true);
    });
});

when I am using this command to run the unit test:

istanbul cover _mocha ./test/demo.js

show the log output like this:

  A suite
    1) contains spec with an expectation


  0 passing (6ms)
  1 failing

  1) A suite
       contains spec with an expectation:
     ReferenceError: expect is not defined
      at Context.<anonymous> (test/demo.js:7:7)

what should I do avoid this problem? the node version is v10.24.1.The jasmine info:

  • jasmine v3.10.0
  • jasmine-core v3.10.1

I have tried to install jasmine-expect using this command:

npm install jasmine-expect --save-dev

still not fix it. Tried jasmine like this:

global.expect = require('jasmine-expect').expect;
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda