Skip to content

Commit 9e3d58f

Browse files
authored
Fix lost links, formatting, and indentation in the migration guide (#2649)
* Fix lost links, formatting, and indentation in the migration guide The links had became unclickable plain text. The code blocks became unformatted and unintented. There used to be a link from the word "changed" to https://sinonjs.org/fake-timers per [1]. This link was removed, which seems fine, but the full stop after it was also removed. [1]: https://web.archive.org/web/20210307205357/https://sinonjs.org/guides/migrating-to-3.0
1 parent 598dddb commit 9e3d58f

File tree

1 file changed

+45
-41
lines changed

1 file changed

+45
-41
lines changed

docs/guides/migration-guide.md

+45-41
Original file line numberDiff line numberDiff line change
@@ -57,31 +57,28 @@ Removes option to pass a custom formatter.
5757
## Sinon 7
5858

5959
For 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
6161
internally. 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

6969
There should be no reason for any code changes with the new Sinon 6.
7070
Usually, `MAJOR` releases should come with breaking changes, but there are
7171
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
7574
has been resolved).
7675

7776
If 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`.
8582
This 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.
108105
In earlier versions, you would manually have to create sandboxes and keep
109106
references to them in order to restore them.
110107

108+
```js
111109
const sandbox = sinon.createSandbox();
112110

113111
describe("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
122121

122+
```js
123123
describe("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`.
135135
This 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
146145
breaking changes in `sinon@3`.
147146
This guide will walk you through those changes.
148147

149148
## `sinon.stub(object, "method", func)` - Removed
150149

151150
Please use `sinon.stub(obj, "method").callsFake(func)` instead.
152151

152+
```js
153153
var 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
158159
upgrade your code
159160

160161
## `sinon.stub(object, property, value)` - Removed
161162

162163
Calling `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.
168169
To define which methods to fake,
169170
please 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
174175
The changes in configuration for fake timers implicitly affect sandbox creation.
175176
If your config used to look
176177
like `{ 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

182182
Trying to stub a non-existing property will now fail to ensure you are
183183
creating
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
224223
three functions now allow the logger to be configured on a per-use basis. In
225224
v1.x you may have written:
226225

226+
```js
227227
sinon.log = function (msg) { // your logging impl };
228+
```
228229
229230
You would now individually import and configure the utility upon creation:
230231
232+
```js
231233
var sinon = require("sinon");
232234

233235
var 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
248249
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).
252252
253+
```js
253254
// Old
254255
sinon.stub(obj, "meth", fn);
255256
// New
256257
sinon.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
262264
separate methods for resetting the history and the behaviour. To mimic the
263265
old behaviour replace all `stub.reset()` calls with `stub.resetHistory()`.
264266
267+
```js
265268
// Old
266269
stub.reset();
267270
// New
268271
stub.resetHistory();
272+
```
269273
270274
## Deprecation of internal helpers
271275

0 commit comments

Comments
 (0)