Skip to content

Commit bb51e07

Browse files
committed
Switch to pure CommonJS
Now that we have dependencies, anything else is just fiddly.
1 parent fc9f868 commit bb51e07

15 files changed

+333
-531
lines changed

README.md

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -218,30 +218,9 @@ chai.should();
218218

219219
You can of course put this code in a common test fixture file; for an example using [Mocha][], see [the Chai as Promised tests themselves][fixturedemo].
220220

221-
### AMD
221+
### In the Browser
222222

223-
Chai as Promised supports being used as an [AMD][amd] module, registering itself anonymously (just like Chai). So, assuming you have configured your loader to map the Chai and Chai as Promised files to the respective module IDs `"chai"` and `"chai-as-promised"`, you can use them as follows:
224-
225-
```javascript
226-
define(function (require, exports, module) {
227-
var chai = require("chai");
228-
var chaiAsPromised = require("chai-as-promised");
229-
230-
chai.use(chaiAsPromised);
231-
232-
// and Chai setup code as above
233-
});
234-
```
235-
236-
### `<script>` tag
237-
238-
If you include Chai as Promised directly with a `<script>` tag, after the one for Chai itself, then it will automatically plug in to Chai and be ready for use:
239-
240-
```html
241-
<script src="chai.js"></script>
242-
<script src="chai-as-promised.js"></script>
243-
<!-- and Chai setup code as above -->
244-
```
223+
To use Chai as Promised in environments that don't support Node.js-like CommonJS modules, you'll need to use a bundling tool like [browserify][].
245224

246225
### Karma
247226

@@ -265,3 +244,4 @@ Chai as Promised is only compatible with modern browsers (IE ≥9, Safari ≥6,
265244
[sinon-chai]: https://github.com/domenic/sinon-chai
266245
[Karma]: https://karma-runner.github.io/
267246
[karma-chai-as-promised]: https://github.com/vlkosinov/karma-chai-as-promised
247+
[browserify]: http://browserify.org/

lib/chai-as-promised.js

Lines changed: 319 additions & 341 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,15 @@
2323
"test": "npm run test-plugin && npm run test-intercompatibility",
2424
"test-plugin": "mocha",
2525
"test-intercompatibility": "mocha test-intercompatibility --opts test-intercompatibility/mocha.opts",
26-
"test-browser-jquery": "coffee ./test/browser/runner.coffee jquery",
27-
"test-browser-q": "coffee ./test/browser/runner.coffee q",
28-
"test-browser-when": "coffee ./test/browser/runner.coffee when",
2926
"lint": "jshint ./lib",
3027
"cover": "istanbul cover node_modules/mocha/bin/_mocha && opener ./coverage/lcov-report/lib/chai-as-promised.js.html"
3128
},
32-
"peerDependencies": {
33-
"chai": ">= 2.1.2 < 4",
29+
"dependencies": {
3430
"check-error": "^1.0.2"
3531
},
32+
"peerDependencies": {
33+
"chai": ">= 2.1.2 < 4"
34+
},
3635
"devDependencies": {
3736
"chai": "^3.0.0",
3837
"coffee-script": "1.10.0",

test/assert-eventually.coffee

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"use strict"
2+
{ shouldPass, shouldFail } = require("./support/common.js")
23

34
describe "Assert interface with eventually extender:", =>
45
promise = null

test/assert-promise-specific.coffee

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"use strict"
2+
{ shouldPass, shouldFail } = require("./support/common.js")
23

34
describe "Assert interface:", =>
45
promise = null

test/browser/libraries/jquery.coffee

Lines changed: 0 additions & 36 deletions
This file was deleted.

test/browser/libraries/q.coffee

Lines changed: 0 additions & 12 deletions
This file was deleted.

test/browser/libraries/when.coffee

Lines changed: 0 additions & 29 deletions
This file was deleted.

test/browser/runner.coffee

Lines changed: 0 additions & 28 deletions
This file was deleted.

test/browser/template.html

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)