From ac7205598e7667e636082ebbe0284b19063d619f Mon Sep 17 00:00:00 2001 From: "Rico Sta. Cruz" Date: Sat, 4 Jul 2015 00:03:12 +0800 Subject: [PATCH 1/5] Update package.json with more metadata --- package.json | 42 +++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/package.json b/package.json index 481e3a5..a91bcab 100644 --- a/package.json +++ b/package.json @@ -1,21 +1,10 @@ { "name": "mocha-jsdom", - "version": "0.5.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": "Rico Sta. Cruz ", - "license": "MIT", - "keywords": [ - "mocha", - "jsdom" - ], - "repository": { - "type": "git", - "url": "https://github.com/rstacruz/mocha-jsdom.git" + "version": "0.5.0", + "author": "Rico Sta. Cruz ", + "bugs": { + "url": "https://github.com/rstacruz/mocha-jsdom/issues" }, "devDependencies": { "blanket": "^1.1.6", @@ -28,8 +17,27 @@ "mocha-standard": "0.0.5", "standard": "^4.3.3" }, + "directories": { + "example": "example", + "test": "test" + }, + "homepage": "https://github.com/rstacruz/mocha-jsdom#readme", + "keywords": [ + "jsdom", + "mocha" + ], + "license": "MIT", + "main": "index.js", "peerDependencies": { - "mocha": "*", - "jsdom": "*" + "jsdom": "*", + "mocha": "*" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/rstacruz/mocha-jsdom.git" + }, + "scripts": { + "coverage": "env COVERAGE=1 mocha -R html-cov > coverage.html && open coverage.html", + "test": "mocha" } } From 4da16d5996d4f8e1287600838ddaf831677bf7e7 Mon Sep 17 00:00:00 2001 From: "Rico Sta. Cruz" Date: Sat, 4 Jul 2015 00:04:12 +0800 Subject: [PATCH 2/5] Add testling support --- README.md | 2 ++ browser.js | 6 ++++++ package.json | 3 ++- 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 browser.js diff --git a/README.md b/README.md index 6a59583..1d21308 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,8 @@ describe('mocha tests', function () { }) ``` +See [example](example/) for an example on how it's used. +
## Node and io.js information diff --git a/browser.js b/browser.js new file mode 100644 index 0000000..4730de4 --- /dev/null +++ b/browser.js @@ -0,0 +1,6 @@ +/* + * A noop version in case your tests are browserified (eg, when using + * testling). + */ + +module.exports = function () {} diff --git a/package.json b/package.json index a91bcab..912125d 100644 --- a/package.json +++ b/package.json @@ -39,5 +39,6 @@ "scripts": { "coverage": "env COVERAGE=1 mocha -R html-cov > coverage.html && open coverage.html", "test": "mocha" - } + }, + "browser": "browser.js" } From d282e6a1ac083d4f57019a30e0ce0c456d13b301 Mon Sep 17 00:00:00 2001 From: "Rico Sta. Cruz" Date: Sat, 4 Jul 2015 00:09:47 +0800 Subject: [PATCH 3/5] Move examples --- README.md | 2 +- example/src.js => examples/misc/error.js | 9 +++++++-- example/error.js => examples/misc/src.js | 6 +++++- package.json | 1 - 4 files changed, 13 insertions(+), 5 deletions(-) rename example/src.js => examples/misc/error.js (63%) rename example/error.js => examples/misc/src.js (67%) diff --git a/README.md b/README.md index 1d21308..b794dfb 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ describe('mocha tests', function () { }) ``` -See [example](example/) for an example on how it's used. +See [examples](examples/) for examples on how it's used.
diff --git a/example/src.js b/examples/misc/error.js similarity index 63% rename from example/src.js rename to examples/misc/error.js index 73f4235..5c54eb5 100644 --- a/example/src.js +++ b/examples/misc/error.js @@ -1,8 +1,13 @@ /* global it, expect, describe */ /* jshint expr: true */ -var jsdom = require('../index') -describe('src', function () { +/* + * run `mocha error.js` to see this fail. + */ + +var jsdom = require('../../index') + +describe('error', function () { jsdom({ src: "(function () { throw new Error('ffff'); })()" }) diff --git a/example/error.js b/examples/misc/src.js similarity index 67% rename from example/error.js rename to examples/misc/src.js index 896b1a6..e15e89f 100644 --- a/example/error.js +++ b/examples/misc/src.js @@ -1,7 +1,11 @@ /* global describe, it, expect */ +/* + * run `mocha src.js` to see this fail. + */ + describe('src', function () { - require('../index')({ + require('../../index')({ src: '}}' }) diff --git a/package.json b/package.json index 912125d..b0d3a7d 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,6 @@ "standard": "^4.3.3" }, "directories": { - "example": "example", "test": "test" }, "homepage": "https://github.com/rstacruz/mocha-jsdom#readme", From 1f1a1d8fbd9cd15b1671dc3a0705bdf708dff853 Mon Sep 17 00:00:00 2001 From: "Rico Sta. Cruz" Date: Sat, 4 Jul 2015 00:14:53 +0800 Subject: [PATCH 4/5] Add more tests --- examples/basic/README.md | 2 ++ examples/basic/index.html | 21 +++++++++++++++++++++ examples/basic/setup.js | 8 ++++++++ examples/basic/test.js | 13 +++++++++++++ examples/failures/README.md | 3 +++ examples/{misc/error.js => failures/one.js} | 4 ---- examples/{misc/src.js => failures/two.js} | 4 ---- 7 files changed, 47 insertions(+), 8 deletions(-) create mode 100644 examples/basic/README.md create mode 100644 examples/basic/index.html create mode 100644 examples/basic/setup.js create mode 100644 examples/basic/test.js create mode 100644 examples/failures/README.md rename examples/{misc/error.js => failures/one.js} (84%) rename examples/{misc/src.js => failures/two.js} (79%) diff --git a/examples/basic/README.md b/examples/basic/README.md new file mode 100644 index 0000000..86095e6 --- /dev/null +++ b/examples/basic/README.md @@ -0,0 +1,2 @@ +This is a basic example of what you can put in your project's `test/` folder. +It will allow you to run tests in both jsdom (iojs/node) and the browser. diff --git a/examples/basic/index.html b/examples/basic/index.html new file mode 100644 index 0000000..f59a21d --- /dev/null +++ b/examples/basic/index.html @@ -0,0 +1,21 @@ + + + + Mocha + + + + + +
+ + + + + + + + + + + diff --git a/examples/basic/setup.js b/examples/basic/setup.js new file mode 100644 index 0000000..d1a071b --- /dev/null +++ b/examples/basic/setup.js @@ -0,0 +1,8 @@ +if (typeof process === 'object') { + // Initialize node environment + global.expect = require('chai').expect + require('mocha-jsdom')() +} else { + window.expect = window.chai.expect + window.require = function () { /*noop*/ } +} diff --git a/examples/basic/test.js b/examples/basic/test.js new file mode 100644 index 0000000..70274c5 --- /dev/null +++ b/examples/basic/test.js @@ -0,0 +1,13 @@ +require('./setup') + +describe('my library', function () { + var mylib + + before(function () { + mylib = require('mylib') || window.mylib + }) + + it('works', function () { + expect(mylib.greet()).to.eql('hola') + }) +}) diff --git a/examples/failures/README.md b/examples/failures/README.md new file mode 100644 index 0000000..7222b4e --- /dev/null +++ b/examples/failures/README.md @@ -0,0 +1,3 @@ +These examples are here so you can see what failures look like. + +Run `mocha one.js` or `mocha two.js` to see. diff --git a/examples/misc/error.js b/examples/failures/one.js similarity index 84% rename from examples/misc/error.js rename to examples/failures/one.js index 5c54eb5..f710ae0 100644 --- a/examples/misc/error.js +++ b/examples/failures/one.js @@ -1,10 +1,6 @@ /* global it, expect, describe */ /* jshint expr: true */ -/* - * run `mocha error.js` to see this fail. - */ - var jsdom = require('../../index') describe('error', function () { diff --git a/examples/misc/src.js b/examples/failures/two.js similarity index 79% rename from examples/misc/src.js rename to examples/failures/two.js index e15e89f..90ed1aa 100644 --- a/examples/misc/src.js +++ b/examples/failures/two.js @@ -1,9 +1,5 @@ /* global describe, it, expect */ -/* - * run `mocha src.js` to see this fail. - */ - describe('src', function () { require('../../index')({ src: '}}' From d5945df924be883a6c2def12bd86a54d3f56e035 Mon Sep 17 00:00:00 2001 From: "Rico Sta. Cruz" Date: Sat, 4 Jul 2015 00:20:26 +0800 Subject: [PATCH 5/5] Release v1.0.0 --- HISTORY.md | 7 +++++++ README.md | 12 +++++++++++- package.json | 2 +- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index c857bad..f7a9655 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,10 @@ +## [v1.0.0] - Jul 4, 2015 + +* Add testling/browserify support. +* Add more examples. + +[v1.0.0]: https://github.com/rstacruz/mocha-jsdom/compare/v0.5.0...v1.0.0 + ## [v0.5.0] - Jun 26, 2015 * Add `rerequire()` to help with using mocha-jsdom with `mocha --watch`. diff --git a/README.md b/README.md index b794dfb..7617160 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ describe('mocha tests', function () { }) ``` -See [examples](examples/) for examples on how it's used. +See [examples/basic](examples/basic) for an example of a basic setup.
@@ -90,6 +90,8 @@ describe('mocha tests', function () { }) ``` +See [examples/basic](examples/basic) for an example of a basic setup. +
## Using with a library, alternate @@ -166,6 +168,14 @@ Other mocha-jsdom specific options:
+## Testling support + +Yes, fully compatible with testling. A test suite using jsdom should be able to use testling. + +See [examples/basic](examples/basic/) for a setup that allows for testing via iojs (jsdom), testling, and mocha via the browser. + +
+ ## Thanks **mocha-jsdom** © 2014+, Rico Sta. Cruz. Released under the [MIT] License.
diff --git a/package.json b/package.json index b0d3a7d..450e614 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "mocha-jsdom", "description": "Simple integration of jsdom into mocha tests", - "version": "0.5.0", + "version": "1.0.0", "author": "Rico Sta. Cruz ", "bugs": { "url": "https://github.com/rstacruz/mocha-jsdom/issues"