Created
January 21, 2016 01:13
-
-
Save fraserxu/a584793306d8db0f258a to your computer and use it in GitHub Desktop.
Build a jQuery ready DOM environment for JSDOM
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
import fs from 'fs' | |
import jsdom from 'jsdom' | |
import resolve from 'resolve' | |
const jQuery = fs.readFileSync(resolve.sync('jquery'), 'utf-8') | |
jsdom.env('<!doctype html><html><body></body></html>', { | |
src: [jQuery] | |
}, (err, window) => { | |
console.log('Voilà!', window.$('body')) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment