Let say I have "js" folder with the file "test.js" and only one function inside:
function isEven(number) {
if (num%2 !== 0) return false;
return true;
}
So, I write this code to test that JS file/code:
var chai = require('chai');
var expect = chai.expect;
var testObject = require('../js/test');
describe('Check isEven()', function() {
it('Should return boolean', function() {
var result = isEven(77);
expect(result).to.be.a('boolean');
});
});
But this produces "undefined is not a function". So, how am I supposed to access code from included file in this case?
PS: I've seen similar stuff, done with Require.js, but what if my app doesn't use Require.js at all?
Aucun commentaire:
Enregistrer un commentaire