You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you experience any issues moving from Sinon 6 to Sinon 7, please
65
+
[let us know](https://github.com/sinonjs/sinon/issues/new?template=Bug_report.md)!
66
66
67
67
## Sinon 6
68
68
69
69
There should be no reason for any code changes with the new Sinon 6.
70
70
Usually, `MAJOR` releases should come with breaking changes, but there are
71
71
no known breaking changes in `sinon@6` at the time of this writing. We chose
72
-
to release a new major version as a pragmatic solution to some noise related
73
-
to releasing Sinon 5.1 https://github.com/sinonjs/sinon/pull/1829#issue-
74
-
193284761, which featured some breaking changes related to ESM (which since
72
+
to release a new major version as a [pragmatic solution to some noise related to releasing Sinon 5.1](https://github.com/sinonjs/sinon/pull/1829#issue-193284761),
73
+
which featured some breaking changes related to ESM (which since
75
74
has been resolved).
76
75
77
76
If you should experience any issues moving from Sinon 5 to Sinon 6, please
[let us know](https://github.com/sinonjs/sinon/issues/new?template=Bug_report.md)!
80
78
81
79
## Sinon 5
82
80
83
-
As with all `MAJOR` releases in semver http://semver.org/, there are
84
-
breaking changes in `sinon@5`.
81
+
As with all `MAJOR` releases in [semver](http://semver.org/), there are breaking changes in `sinon@5`.
85
82
This guide will walk you through those changes.
86
83
87
84
## `spy.reset()` is removed, use `spy.resetHistory()`
@@ -108,63 +105,67 @@ Now would be a good opportunity to tidy up your tests.
108
105
In earlier versions, you would manually have to create sandboxes and keep
As with all `MAJOR` releases in semver http://semver.org/, there are
134
-
breaking changes in `sinon@4`.
134
+
As with all `MAJOR` releases in [semver](http://semver.org/), there are breaking changes in `sinon@4`.
As with all `MAJOR` releases in semverhttp://semver.org/, there are
144
+
As with all `MAJOR` releases in [semver](http://semver.org/), there are
146
145
breaking changes in `sinon@3`.
147
146
This guide will walk you through those changes.
148
147
149
148
## `sinon.stub(object, "method", func)` - Removed
150
149
151
150
Please use `sinon.stub(obj, "method").callsFake(func)` instead.
152
151
152
+
```js
153
153
var stub =sinon.stub(obj, "stubbedMethod").callsFake(function () {
154
-
return 42;
154
+
return42;
155
155
});
156
+
```
156
157
157
-
A codemod is availablehttps://github.com/hurrymaplelad/sinon-codemod to
158
+
A [codemod is available](https://github.com/hurrymaplelad/sinon-codemod) to
@@ -224,36 +223,39 @@ configure `FakeServer`, `FakeXMLHttpRequest` and `FakeXDomainRequest`; these
224
223
three functions now allow the logger to be configured on a per-use basis. In
225
224
v1.x you may have written:
226
225
226
+
```js
227
227
sinon.log=function (msg) { // your logging impl };
228
+
```
228
229
229
230
You would now individually import and configure the utility upon creation:
230
231
232
+
```js
231
233
var sinon =require("sinon");
232
234
233
235
var myFakeServer =sinon.fakeServer.create({
234
-
logger: function (msg) { // your logging impl }
236
+
logger:function (msg) { // your logging impl }
235
237
});
238
+
```
236
239
237
240
## sinon.test, sinon.testCase and sinon.config Removed
238
241
239
242
`sinon.test` and `sinon.testCase` have been extracted from the Sinon API and
240
-
moved into their own node module, sinon-test
241
-
https://www.npmjs.com/package/sinon-test. Please refer to the sinon-test
242
-
README https://github.com/sinonjs/sinon-test/blob/master/README.md for
243
-
migration examples.
243
+
moved into their own node module, [sinon-test](https://www.npmjs.com/package/sinon-test).
244
+
Please refer to the [sinon-test README](https://github.com/sinonjs/sinon-test/blob/master/README.md) for migration examples.
244
245
245
246
## stub.callsFake replaces stub(obj, 'meth', fn)
246
247
247
248
`sinon.stub(obj, 'meth', fn)` return a spy, not a full stub. Behavior could
248
249
not be redefined. `stub.callsFake`
249
-
now returns a full stub. Here's a codemod script
250
-
https://github.com/hurrymaplelad/sinon-codemod to help you migrate.
251
-
See discussion https://github.com/sinonjs/sinon/pull/823.
250
+
now returns a full stub. Here's a [codemod script](https://github.com/hurrymaplelad/sinon-codemod) to help you migrate.
251
+
See [discussion](https://github.com/sinonjs/sinon/pull/823).
252
252
253
+
```js
253
254
// Old
254
255
sinon.stub(obj, "meth", fn);
255
256
// New
256
257
sinon.stub(obj, "meth").callsFake(fn);
258
+
```
257
259
258
260
## stub.resetHistory replaces stub.reset
259
261
@@ -262,10 +264,12 @@ Previously `stub.reset()` only reset the history of the stub. Stubs now have
262
264
separate methods for resetting the history and the behaviour. To mimic the
263
265
old behaviour replace all `stub.reset()` calls with `stub.resetHistory()`.
0 commit comments