-
-
Notifications
You must be signed in to change notification settings - Fork 769
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid tampering with globals and other modules' exports in tests (#2504)
* fix: do not modify the Function prototype when running tests Made a single test fail as the Function prototype had been mutated by a later test in the test suite. refs #2502 * fix: do not mutate matcher object message This made 3 of the assertion tests fail when re-running as Sinon's spy formatter changed the exports of the samsam module * Use latest version of samsam to get immutable messages Ensure we cannot do the same mistake again
- Loading branch information
Showing
5 changed files
with
60 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
"use strict"; | ||
const { D } = require("./../lib/sinon/spy-formatters"); | ||
const sinon = require("../lib/sinon"); | ||
const { assert } = require("@sinonjs/referee"); | ||
|
||
describe('formatter specifier "D"', function () { | ||
it("should not mutate matchers passed as arguments", function () { | ||
const matcher = sinon.match(function test() { | ||
return false; | ||
}, "something"); | ||
assert.equals(matcher.message, "something"); | ||
|
||
const stub = sinon.stub(); | ||
|
||
stub(1, 2, 3); | ||
/* eslint-disable new-cap */ | ||
D(stub, [matcher]); | ||
|
||
assert.equals(matcher.message, "something"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters