{"name":"mocha-jsdom","description":"Simple integration of jsdom into mocha tests","version":"1.2.0","author":{"name":"Rico Sta. Cruz","email":"rico@ricostacruz.com"},"bugs":{"url":"https://github.com/rstacruz/mocha-jsdom/issues"},"devDependencies":{"chai":"4.1.2","istanbul":"0.4.5","jquery":"3.3.1","jsdom":"~11.11.0","mocha":"5.2.0","mocha-standard":"1.0.0","standard":"11.0.1"},"directories":{"test":"test"},"homepage":"https://github.com/rstacruz/mocha-jsdom#readme","keywords":["jsdom","mocha"],"license":"MIT","main":"index.js","peerDependencies":{"jsdom":">10.0.0","mocha":"*"},"repository":{"type":"git","url":"git+https://github.com/rstacruz/mocha-jsdom.git"},"scripts":{"coverage":"istanbul cover _mocha -- -R spec","test":"mocha"},"browser":"browser.js","gitHead":"05115ca432e211f12bd73db2ad342bbe99ab054c","_id":"mocha-jsdom@1.2.0","_npmVersion":"6.0.1","_nodeVersion":"8.10.0","_npmUser":{"name":"rstacruz","email":"dropbox@ricostacruz.com"},"dist":{"integrity":"sha512-G8GmJpSvAH4K6TyaBMZUzdOdLZ0JqbNuPmSGg9I8BDyC3/9CAOZnnhP+g2XDIgKVjW7kiwphmI2porYf70Zzmw==","shasum":"779905bde5ff50915c27cf633c785d2807a81b44","tarball":"http://registry-npm.ywwl.com/mocha-jsdom/download/mocha-jsdom-1.2.0.tgz","fileCount":26,"unpackedSize":89132,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbFcNNCRA9TVsSAnZWagAA6osQAKUVPAGBZhX3eO69T3hB\n2LogIlvqmbBJrb1d/+SKgb61P7oliyeTznDJphLlMuPNi2sKYKDMwiqv+Gyh\ne7fs5BgjGxfTNA2yUOo+BSg3K8spyeddab3IGFcYytFwzVkGTECt/3rU4k/4\nPlEsKTcEIdpl31j4zL17+qfcQ7QFJyb6kaeThDX3ctA2eeKI4Rk71Bk6UBlY\nX0T/1kgpjihj8peqzpT7X79dccC9WWwTXsa5AHbyrGZgd9/MI2inh1MoDEVm\n12Djl37fPw5RNe9GRT10hR77RzNufG1XZPktvRhqK59OSLJuXFwLnlYzwWOt\nnvlpbLZJzK8ShvfNQBLHuceS2LmO2mSaqyVbiCJmpBApV3AvYX9Yt9SaIRrh\nVBw4fOtCm1yzE3GAytzdVT6FNO8GoKDW62CZkcPA7O15eEWw4FCsxkynXY9G\n8JIyUMjei5bN00nclizFkSAwKtpldWT1PnfnwIvFnT0pT6xeMuGNph+R59yV\nebuQK1YC8UNfBrY+Ox1Yd8p4JLpOgIQtRG9eU1OLpczPasnPFJmdcpMLNva2\n78PQv3RXZIqmn3FTb5FTuQmzkf7d1DHGsQg/TMien/mrPYvAlAwRF2GgWckM\n6gvN26LDiXMSVYiVZD3ACyWCLpp7wPpMOdkpiRE02DsEG542FY7kfS+RMQ16\nE1T0\r\n=4nAd\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIF+px099ZjGeYRFIaqpvvxr86+2u8qwE6U3qWPGOWAr2AiArJpRnYBtSKoXvDCHmf5flucIfh+ExnJgOWAdpA9gm+g=="}],"size":28667,"noattachment":false,"key":"/mocha-jsdom/-/mocha-jsdom-1.2.0.tgz"},"maintainers":[{"name":"rstacruz","email":"rico@ricostacruz.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mocha-jsdom_1.2.0_1528152908413_0.02215234697749935"},"_hasShrinkwrap":false,"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":1528152908499,"_cnpm_publish_time":1528152908499,"dist-tags":{"latest":"2.0.0"}}