Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jacob414/mocha-jsdom
Experiment to run Mocha tests with a JSDom generated DOM (in Node.js)
https://github.com/jacob414/mocha-jsdom
Last synced: 5 days ago
JSON representation
Experiment to run Mocha tests with a JSDom generated DOM (in Node.js)
- Host: GitHub
- URL: https://github.com/jacob414/mocha-jsdom
- Owner: jacob414
- Created: 2014-02-20T13:36:23.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-02-20T13:56:47.000Z (over 10 years ago)
- Last Synced: 2023-03-11T13:02:27.752Z (over 1 year ago)
- Language: JavaScript
- Size: 113 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Mocha tests under Node.js with a jsdom
This is a proof of concept project to find a convenient way of running
Mocha tests via the Node.js runner using
[jsdom](https://www.npmjs.org/package/jsdom), to create a more browser
like environment. You might want to do that to test symantic aspects
of your program in Node.js without having to load the entire thing in
a browser, mostly for performance reasons.The callback based ways described in jsdom's page will have a little
hard time to trigger Mocha to run your suites, so to do this you need
to use the methods described by jsdom's docs as "For the
hardcore". Actually it isn't that difficult, and this little project
shows how to do it.## How to try:
Manual (at least for now). Clone, then prepare your directory by
running a `npm install`:$ npm install
You should see lots of output.
Have a look at the `test.js` file. It initializes a `jsdom` object in
the `describe` function and points a closure local '`document`' to it
in a way that preceding tests will have an environment that reasonably
much resembles a web browser. The `run.sh` script will run the spec.A somewhat uglier but more realistic simulation for larger codebases
would be to assign the return value of the call to `jsdom.jsdom` to
`global.document`.