Last active
January 11, 2018 22:30
-
-
Save peteristhegreat/5835942b6a31bdabf8e943b891395178 to your computer and use it in GitHub Desktop.
NodeJs JQuery Jest, run tests on browser side javascript functions without modules, requirejs or commonjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// npm install jquery | |
var $ = require('jquery') | |
// read in your script from the filesystem | |
const fs = require('fs'); | |
var text = fs.readFileSync('static/js/sum.js'); | |
// Note, this is a dirty hack to not have to add modules and start using browserify or rollup or webpack or ES6. | |
$.globalEval(text); | |
test('getColumnIdFromTagId testing', () => { | |
console.log("before test"); | |
expect(sum(1,1).toBe(2); | |
expect(sum(2,2).toBe(4); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment