sinon-test
Advanced tools
Comparing version 2.3.0 to 2.4.0
2.4.0 / 2018-10-19 | ||
================== | ||
* Update sinon peerDependency to allow 6.x | ||
2.3.0 / 2018-09-06 | ||
@@ -3,0 +8,0 @@ ================== |
{ | ||
"name": "sinon-test", | ||
"version": "2.3.0", | ||
"version": "2.4.0", | ||
"description": "", | ||
@@ -52,7 +52,7 @@ "main": "lib/index.js", | ||
"rollup-plugin-commonjs": "^9.1.3", | ||
"sinon": "^6.1.5" | ||
"sinon": "^7.0.0" | ||
}, | ||
"peerDependencies": { | ||
"sinon": "2.x - 6.x" | ||
"sinon": "2.x - 7.x" | ||
} | ||
} |
@@ -32,3 +32,3 @@ # Sinon Test | ||
```javascript | ||
it('should do something', sinonTest(function(){ | ||
it('should do something', test(function(){ | ||
var spy1 = this.spy(myFunc); | ||
@@ -61,8 +61,6 @@ var spy2 = this.spy(myOtherFunc); | ||
or just add it as a `<script src="dist/sinon-test.js"></script>` | ||
tag to the html where you write your tests. A pre-built browser | ||
version can be found in the NPM package under `dist/sinon-test.js`. | ||
## Usage | ||
### Node and CommonJS build systems | ||
Once initialized, the package creates a context for your test based on a sinon sandbox. | ||
@@ -83,4 +81,4 @@ You can use `this` in a wrapped test function to create sinon spies, stubs, etc. | ||
var sinon = require('sinon'); | ||
var sinonTestFactory = require('sinon-test'); | ||
var sinonTest = sinonTestFactory(sinon); | ||
var sinonTest = require('sinon-test'); | ||
var test = sinonTest(sinon); | ||
var assert = require('assert'); | ||
@@ -91,3 +89,3 @@ | ||
it('should do something', sinonTest(function(){ | ||
it('should do something', test(function(){ | ||
var spy = this.spy(myFunc); | ||
@@ -101,6 +99,30 @@ myFunc(1); | ||
### Direct browser usage | ||
In place of the `require` statements indicated above, in the | ||
browser, you should simply reference the global `sinonTest` after | ||
including a script tag in your HTML: | ||
```html | ||
<script src="dist/sinon-test.js"></script> | ||
``` | ||
Or if you are in an ES6 Modules environment (modern browsers only), you | ||
only need to add an import statement: | ||
```html | ||
<script type="module"> | ||
import sinon from './node_modules/sinon/pkg/sinon-esm.js'; | ||
import sinonTest from './node_modules/sinon-test/dist/sinon-test-es.js'; | ||
const test = sinonTest(sinon); | ||
it('should work', test(function() { | ||
pass(); | ||
})); | ||
</script> | ||
``` | ||
## API | ||
```javascript | ||
const sinonTest = require('sinon-test')(sinon); | ||
const test = require('sinon-test')(sinon); | ||
``` | ||
@@ -111,3 +133,3 @@ | ||
```js | ||
const sinonTest = require('sinon-test')(sinon, {useFakeTimers: false}); | ||
const test = require('sinon-test')(sinon, {useFakeTimers: false}); | ||
``` | ||
@@ -119,3 +141,3 @@ | ||
```javascript | ||
sinon.test = sinonTest; | ||
sinon.test = test; | ||
``` |
24530
137