I am using mocha
to perform my unit tests of the web layer, and it generates the error:
$ is not defined
Can I be missing something else to recognize the $
of jQuery
?
The code of my test is:
var assert = require('assert');
var chai = require('chai');
var expect = chai.expect;
var utils = require('../js/utils');
describe('UtilsSuite', function() {
describe('#isUsuarioAdministradorExperto c2', function() {
before(function () {
global.$ = global.jQuery = require('jquery');
});
it('Cuando el estado no pertence entre los disponible retorna vacio ', function (){
console.log(utils.mostrarFechaSolucion('02/02/2002','SITIO_GSM_NORMAL'));
assert.equal("",utils.mostrarFechaSolucion('02/02/2002','SITIO_GSM_NORMAL'));
});
});
});
and the code of my function is:
exports.mostrarFechaSolucion = function (fechaSolucion, estadoTecnico) {
return ($.inArray(estadoTecnico, estadosFechaSolucion) > -1) ?
"<tr><td class='encabezado'>Fecha solución:</td><td class='datosSitio'>" + fechaSolucion + "</td></tr>" : "";
};