Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: assertion log limit #2485

Merged
merged 8 commits into from Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 17 additions & 1 deletion lib/sinon/assert.js
Expand Up @@ -333,4 +333,20 @@ function createAssertObject(opts) {
}

module.exports = createAssertObject();
module.exports.createAssertObject = createAssertObject;
Object.defineProperty(module.exports, "createAssertObject", {
get() {
return createAssertObject;
},
});

// allow for easy mocking
module.exports.mock = {};
Object.defineProperty(module.exports.mock, "createAssertObject", {
fatso83 marked this conversation as resolved.
Show resolved Hide resolved
get() {
return createAssertObject;
},
set(newImpl) {
// eslint-disable-next-line no-func-assign
createAssertObject = newImpl;
},
});
31 changes: 31 additions & 0 deletions test/create-sandbox-test.js
@@ -0,0 +1,31 @@
"use strict";

const sinonAssert = require("../lib/sinon/assert");
const createSandbox = require("../lib/sinon/create-sandbox");

describe("create-sandbox", function () {
it("passes on options to the creation of the assert object", function () {
fatso83 marked this conversation as resolved.
Show resolved Hide resolved
// Arrange
const sb = createSandbox();
const spy = sb.spy();
sb.replace.usingAccessor(sinonAssert.mock, "createAssertObject", spy);

// Act
createSandbox({
assertOptions: {
shouldLimitAssertionLogs: true,
assertionLogLimit: 1234,
},
});

// Assert
sb.assert.calledWith(
spy,
sb.match({
shouldLimitAssertionLogs: true,
assertionLogLimit: 1234,
}),
);
sb.restore();
});
});