Skip to content

Commit

Permalink
Add example on adding assertOptions to the sandbox
Browse files Browse the repository at this point in the history
  • Loading branch information
fatso83 committed Oct 28, 2023
1 parent e6e9521 commit de7f7e0
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
24 changes: 24 additions & 0 deletions docs/release-source/release/examples/sandbox-configuration.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
require("@fatso83/mini-mocha").install();
const sinon = require("sinon");
const { assert } = require("@sinonjs/referee");

it("should allow limiting the length of the assert.fake output", function () {
const sb = sinon.createSandbox({
assertOptions: {
shouldLimitAssertionLogs: true,
assertionLogLimit: 10,
},
});
const reallyLongErrorMessage = "a long string repeated 100 times".repeat(
100,
);

assert.exception(
() => {
sb.assert.fail(reallyLongErrorMessage);
},
{
message: "a long str",
},
);
});
14 changes: 14 additions & 0 deletions docs/release-source/release/sandbox.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,20 @@ console.log(Object.keys(sinon.inject(obj)))
"requests",
```

##### `assertOptions`

You can override the default behavior and limit the amount of
characters if the error strings should somehow be overwhelming
and overflow your display.

```javascript
@property {boolean} shouldLimitAssertionLogs
@property {number} assertionLogLimit
```

<div data-example-id="sandbox-configuration"></div>
```
##### `useFakeTimers`
If set to `true`, the sandbox will have a `clock` property. You can optionally pass
Expand Down

0 comments on commit de7f7e0

Please sign in to comment.