@@ -57,31 +57,28 @@ Removes option to pass a custom formatter.
5757## Sinon 7
5858
5959For users upgrading to Sinon 7 the only known breaking API change is that
60- ** negative ticks** are not allowed in ` Sinon @7` due to updating to lolex 3
60+ ** negative ticks** are not allowed in ` sinon @7` due to updating to lolex 3
6161internally. This means you cannot use negative values in
62- sinon.useFakeTimers().tick();
62+ ` sinon.useFakeTimers().tick() ` ;
6363
64- If you experience any issues moving from Sinon 6 to Sinon 7, please let us
65- know! https://github.com/sinonjs/sinon/issues/new?template=Bug_report.md .
64+ 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 ) !
6666
6767## Sinon 6
6868
6969There should be no reason for any code changes with the new Sinon 6.
7070Usually, ` MAJOR ` releases should come with breaking changes, but there are
7171no 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
7574has been resolved).
7675
7776If you should experience any issues moving from Sinon 5 to Sinon 6, please
78- let us know!
79- https://github.com/sinonjs/sinon/issues/new?template=Bug_report.md .
77+ [ let us know] ( https://github.com/sinonjs/sinon/issues/new?template=Bug_report.md ) !
8078
8179## Sinon 5
8280
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 ` .
8582This guide will walk you through those changes.
8683
8784## ` spy.reset() ` is removed, use ` spy.resetHistory() `
@@ -108,63 +105,67 @@ Now would be a good opportunity to tidy up your tests.
108105In earlier versions, you would manually have to create sandboxes and keep
109106references to them in order to restore them.
110107
108+ ``` js
111109const sandbox = sinon .createSandbox ();
112110
113111describe (" myFunction" , function () {
114- afterEach(function () {
115- sandbox.restore();
116- });
112+ afterEach (function () {
113+ sandbox .restore ();
114+ });
117115
118- it("should make pie");
116+ it (" should make pie" );
119117});
118+ ```
120119
121120### From ` sinon@5.0.0 `
122121
122+ ``` js
123123describe (" myFunction" , function () {
124- afterEach(function () {
125- sinon.restore();
126- });
124+ afterEach (function () {
125+ sinon .restore ();
126+ });
127127
128- it("should make pie");
128+ it (" should make pie" );
129129});
130+ ```
130131
131132## Sinon 4
132133
133- 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 ` .
135135This guide will walk you through those changes.
136136
137137## ` sinon.stub(obj, 'nonExistingProperty') ` - Throws
138138
139- Trying to stub a non-existing property will now fail, to ensure you are
140- creating
141- less error-prone tests https://github.com/sinonjs/sinon/pull/1557 .
139+ Trying to stub a non-existing property will now fail, to ensure you are creating
140+ [ less error-prone tests] ( https://github.com/sinonjs/sinon/pull/1557 ) .
142141
143142## Sinon 3
144143
145- As with all ` MAJOR ` releases in semver http://semver.org/ , there are
144+ As with all ` MAJOR ` releases in [ semver] ( http://semver.org/ ) , there are
146145breaking changes in ` sinon@3 ` .
147146This guide will walk you through those changes.
148147
149148## ` sinon.stub(object, "method", func) ` - Removed
150149
151150Please use ` sinon.stub(obj, "method").callsFake(func) ` instead.
152151
152+ ``` js
153153var stub = sinon .stub (obj, " stubbedMethod" ).callsFake (function () {
154- return 42;
154+ return 42 ;
155155});
156+ ```
156157
157- A codemod is available https://github.com/hurrymaplelad/sinon-codemod to
158+ A [ codemod is available] ( https://github.com/hurrymaplelad/sinon-codemod ) to
158159upgrade your code
159160
160161## ` sinon.stub(object, property, value) ` - Removed
161162
162163Calling ` sinon.stub ` with three arguments will throw an Error. This was
163- deprecated with ` sinon@2 ` and has been removed with ` sinon@3 `
164+ deprecated with ` sinon@2 ` and has been removed with ` sinon@3 ` .
164165
165166## ` sinon.useFakeTimers([now, ]prop1, prop2, ...) ` - Removed
166167
167- ` sinon.useFakeTimers() ` signature has changed
168+ ` sinon.useFakeTimers() ` signature has changed.
168169To define which methods to fake,
169170please use ` config.toFake ` . Other options are now available when configuring
170171` useFakeTimers ` . Please consult the documentation for more information.
@@ -174,15 +175,13 @@ please use `config.toFake`. Other options are now available when configuring
174175The changes in configuration for fake timers implicitly affect sandbox creation.
175176If your config used to look
176177like ` { useFaketimers: ["setTimeout", "setInterval"]} ` , you
177- will now need to change it to `{ useFaketimers: { toFake: [ "setTimeout",
178- "setInterval"] }}`.
178+ will now need to change it to ` { useFaketimers: { toFake: ["setTimeout", "setInterval"] }} ` .
179179
180180## ` sandbox.stub(obj, 'nonExistingProperty') ` - Throws
181181
182182Trying to stub a non-existing property will now fail to ensure you are
183183creating
184- less error-prone tests
185- https://github.com/sinonjs/sinon/issues/1537#issuecomment-323948482 .
184+ [ less error-prone tests] ( https://github.com/sinonjs/sinon/issues/1537#issuecomment-323948482 ) .
186185
187186## Removal of internal helpers
188187
@@ -224,36 +223,39 @@ configure `FakeServer`, `FakeXMLHttpRequest` and `FakeXDomainRequest`; these
224223three functions now allow the logger to be configured on a per-use basis. In
225224v1.x you may have written:
226225
226+ ``` js
227227sinon .log = function (msg ) { // your logging impl };
228+ ` ` `
228229
229230You would now individually import and configure the utility upon creation:
230231
232+ ` ` ` js
231233var sinon = require (" sinon" );
232234
233235var myFakeServer = sinon .fakeServer .create ({
234- logger: function (msg) { // your logging impl }
236+ logger : function (msg ) { // your logging impl }
235237});
238+ ` ` `
236239
237240## sinon.test, sinon.testCase and sinon.config Removed
238241
239242` 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.
244245
245246## stub.callsFake replaces stub(obj, 'meth', fn)
246247
247248` sinon .stub (obj, ' meth' , fn)` return a spy, not a full stub. Behavior could
248249not 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).
252252
253+ ` ` ` js
253254// Old
254255sinon .stub (obj, " meth" , fn);
255256// New
256257sinon .stub (obj, " meth" ).callsFake (fn);
258+ ` ` `
257259
258260## stub.resetHistory replaces stub.reset
259261
@@ -262,10 +264,12 @@ Previously `stub.reset()` only reset the history of the stub. Stubs now have
262264separate methods for resetting the history and the behaviour. To mimic the
263265old behaviour replace all ` stub .reset ()` calls with ` stub .resetHistory ()` .
264266
267+ ` ` ` js
265268// Old
266269stub .reset ();
267270// New
268271stub .resetHistory ();
272+ ` ` `
269273
270274## Deprecation of internal helpers
271275
0 commit comments