{"name":"mocha-jsdom","version":"0.2.0","description":"Simple integration of jsdom into mocha tests","main":"index.js","scripts":{"test":"mocha","coverage":"env COVERAGE=1 mocha -R html-cov > coverage.html && open coverage.html"},"author":{"name":"Rico Sta. Cruz","email":"hi@ricostacruz.com"},"license":"MIT","keywords":["mocha","jsdom"],"repository":{"type":"git","url":"https://github.com/rstacruz/mocha-jsdom.git"},"devDependencies":{"blanket":"^1.1.6","chai":"^1.9.1","coveralls":"^2.11.2","jquery":"^2.1.1","jsdom":"^1.0.0-pre.7","mocha":"^1.21.4","mocha-clean":"^0.2.0","mocha-lcov-reporter":"0.0.1"},"peerDependencies":{"mocha":"*","jsdom":"*"},"gitHead":"e3a9d97157b6ec00ac0c3f8b8f56987a6951e158","bugs":{"url":"https://github.com/rstacruz/mocha-jsdom/issues"},"homepage":"https://github.com/rstacruz/mocha-jsdom","_id":"mocha-jsdom@0.2.0","_shasum":"6e53edb562291c037955360aa33c69bbf6bd20bc","_from":".","_npmVersion":"1.4.28","_npmUser":{"name":"rstacruz","email":"rico@ricostacruz.com"},"maintainers":[{"name":"rstacruz","email":"rico@ricostacruz.com"}],"dist":{"shasum":"6e53edb562291c037955360aa33c69bbf6bd20bc","tarball":"http://registry-npm.ywwl.com/mocha-jsdom/download/mocha-jsdom-0.2.0.tgz","integrity":"sha512-BCzO79/tahTen/WRC9k/3fx7qNNU1aZ26F9pbxcU6uRwkBP/PGWrfzIOWPil+8b+TEhSQk5yT6bjH6Sgpu8+uA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDRd9lNvJPJHsW1tg1Z+S6D2r72xwYZ9ReD56GehLlxUwIgHGWl1l527QpGbMmS6PVxdW6327eZu3NQuAj7LvRvzTQ="}],"size":3826,"noattachment":false,"key":"/mocha-jsdom/-/mocha-jsdom-0.2.0.tgz"},"directories":{},"readme":"> _Deprecation notice:_\n> Consider [jsdom-global](https://github.com/rstacruz/jsdom-global) instead, a simpler alternative that also works outside of Mocha. `mocha-jsdom` still works, but `jsdom-global` is better supported.\n\n---\n\n# mocha-jsdom\n\n> Test frontend libraries in the console using Node.js, [mocha] and [jsdom]. \n\n[![Status](https://travis-ci.org/rstacruz/mocha-jsdom.svg?branch=master)](https://travis-ci.org/rstacruz/mocha-jsdom \"See test builds\")\n\n<br>\n\n## Usage\n\n```sh\n$ npm i --save-dev mocha-jsdom\n```\n\n[![npm version](http://img.shields.io/npm/v/mocha-jsdom.svg?style=flat)](https://npmjs.org/package/mocha-jsdom \"View this project on npm\")\n\nUse `jsdom()` inside your `describe(...)` block (or the global context). It will \nturn your Node.js environment into a mock browser environment supporting the \nfull DOM and browser API. The variables `window`, `document`, `history` (and so \non) will then be available for use.\n\n```js\nvar jsdom = require('mocha-jsdom')\nvar expect = require('chai').expect\n\ndescribe('mocha tests', function () {\n\n  jsdom()\n\n  it('has document', function () {\n    var div = document.createElement('div')\n    expect(div.nodeName).eql('DIV')\n  })\n\n})\n```\n\nSee [examples/basic](examples/basic) for an example of a basic setup.\n\n<br>\n\n## Upgrading to v2.0.0\n\nIf you are coming from mocha-jsdom v1.x, remove `jsdom` if you're not using it before upgrading. `jsdom` is now a direct dependency of `mocha-jsdom`.\n\n```bash\n# using Yarn\nyarn remove jsdom\nyarn upgrade mocha-jsdom\n```\n\n```bash\n# using npm\nnpm uninstall -S -D jsdom\nnpm upgrade mocha-jsdom\n```\n\n<br>\n\n## Node and io.js information\n\nAs of jsdom 4.0.0, [jsdom now requires io.js](https://github.com/tmpvar/jsdom/blob/master/Changelog.md#400) and will not work with Node.js 0.12 or below.\n\n<br>\n\n## How it works\n\nmocha-jsdom is a simple glue to integrate [jsdom] to mocha.\n\nInvoking `jsdom()` will inject `before` and `after` handlers to the current \nmocha suite which will setup and teardown jsdom. Here's what it does:\n\n* __Window__: `global.window` will be available as the jsdom.\n\n* __Globals__: global variables like `document` and `history` are propagated, \n  and they're cleaned up after tests run.\n\n* __Error handling__: jsdom errors are sanitized so that their stack traces are \nshortened.\n\n__NB:__ Before you try this library, learn about jsdom first. In fact, you may be \nable to integrate jsdom into your tests *without* this library; this is mostly \nsyntactic sugar and reasonable defaults.\n\n<br>\n\n## Using with a library\n\nPerfect for testing small DOM-consuming utilities in the console. See \n[test/jquery.js](test/jquery.js) for an example.\n\n```js\ndescribe('mocha tests', function () {\n\n  var $\n  jsdom()\n\n  before(function () {\n    $ = require('jquery')\n  })\n\n  it('works', function () {\n    document.body.innerHTML = '<div>hola</div>'\n    expect($(\"div\").html()).eql('hola')\n  })\n\n})\n```\n\nSee [examples/basic](examples/basic) for an example of a basic setup.\n\n<br>\n\n## Using with a library, alternate\n\nYou can also pass the source code via `src`:\n\n```js\ndescribe('mocha tests', function () {\n  jsdom({\n    src: fs.readFileSync('jquery.js', 'utf-8')\n  })\n\n  ...\n})\n```\n\n<br>\n\n## Configuration\n\nYou can pass jsdom options:\n\n```js\ndescribe('mocha tests', function () {\n  jsdom({\n    parsingMode: 'xml'\n  })\n\n  ...\n})\n```\n\n<br>\n\n## Working with mocha --watch\n\nWhen using with `--watch`, you my encounter strange errors from 3rd-party\nlibraries like jQuery not working properly.\n\nIn these cases, use `require('mocha-jsdom').rerequire` instead of `require()`.\nThis will ensure that the `require()` call will always happen.\n\n```js\nvar $\nvar jsdom = require('mocha-jsdom')\nvar rerequire = jsdom.rerequire\n\njsdom()\n\nbefore(function () {\n  $ = rerequire('jquery')\n})\n```\n\n<br>\n\n## Special config\n\nOther mocha-jsdom specific options:\n\n * `globalize` - propagates to values in `window` to `global`. defaults to true.\n\n * `console` - allows you to use `console.log` inside a jsdom script. defaults \n to true.\n\n * `useEach` - bind to Mocha's `beforeEach`/`afterEach` rather than `before`/`after`.\n defaults to false.\n\n * `skipWindowCheck` - skips checking of `window` at startup. When false,\n mocha-jsdom will throw an error if `window` already exists. Defaults to false.\n\n[jsdom]: https://www.npmjs.org/package/jsdom\n[mocha]: https://www.npmjs.com/package/mocha\n\n<br>\n\n## Testling support\n\nYes, fully compatible with testling. A test suite using jsdom should be able to use testling.\n\nSee [examples/basic](examples/basic/) for a setup that allows for testing via iojs (jsdom), testling, and mocha via the browser.\n\n<br>\n\n## Thanks\n\n> **mocha-jsdom** © 2014-2018 Rico Sta. Cruz. Released under the [MIT] License.<br>\n> Authored and maintained by Rico Sta. Cruz with help from contributors ([list][contributors]).\n\n[![](https://img.shields.io/github/followers/rstacruz.svg?style=social&label=@rstacruz)](https://github.com/rstacruz)\n&nbsp;&nbsp;\n[![](https://img.shields.io/twitter/follow/rstacruz.svg?style=social&label=@rstacruz)](https://twitter.com/rstacruz)\n&nbsp;&nbsp;\n**[ricostacruz.com](http://ricostacruz.com)**\n\n[mit]: http://mit-license.org/\n[contributors]: http://github.com/rstacruz/mocha-jsdom/contributors\n","publish_time":1415169945811,"_cnpm_publish_time":1415169945811,"dist-tags":{"latest":"2.0.0"}}