Skip to content

Instantly share code, notes, and snippets.

@peteristhegreat
Last active January 11, 2018 22:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peteristhegreat/5835942b6a31bdabf8e943b891395178 to your computer and use it in GitHub Desktop.
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
// 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