-
-
Notifications
You must be signed in to change notification settings - Fork 769
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Explain how to update to use the default sandbox
- Loading branch information
Showing
1 changed file
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
--- | ||
layout: page | ||
title: Migrating to v5.0 - Sinon.JS | ||
breadcrumb: migrating to 5.0 | ||
--- | ||
|
||
As with all `MAJOR` releases in [`semver`](http://semver.org/), there are breaking changes in `sinon@5`. | ||
This guide will walk you through those changes. | ||
|
||
## `sinon` is now a (default) sandbox | ||
|
||
Since `[email protected]`, the `sinon` object is a default sandbox. Unless you have a very advanced setup or need a special configuration, you probably want to just use that one. | ||
|
||
The old sandbox API is still available, so you don't **have** to do anything. | ||
|
||
However, switching to using the default sandbox can help make your code more concise. | ||
Now would be a good opportunity to tidy up your tests. | ||
|
||
|
||
### Before `[email protected]` | ||
|
||
In earlier versions, you would manually have to create sandboxes and keep references to them in order to restore them. | ||
|
||
```js | ||
const sandbox = sinon.createSandbox(); | ||
|
||
describe('myFunction', function() { | ||
afterEach(function () { | ||
sandbox.restore(); | ||
}); | ||
|
||
it('should make pie'); | ||
}); | ||
``` | ||
|
||
|
||
### From `[email protected]` | ||
|
||
```js | ||
describe('myFunction', function() { | ||
afterEach(function () { | ||
sinon.restore(); | ||
}); | ||
|
||
it('should make pie'); | ||
}); | ||
``` |