Skip to content

Commit f339591

Browse files
aryaemami59antfu
andcommitted
Fix broken unit tests caused by stubbed process.version
Co-authored-by: Anthony Fu <[email protected]>
1 parent 5ac3927 commit f339591

1 file changed

Lines changed: 13 additions & 8 deletions

File tree

tests/lib/cli-engine/lint-result-cache.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -163,16 +163,21 @@ describe("LintResultCache", () => {
163163
it("contains node version during hashing", () => {
164164
const version = "node-=-version";
165165

166-
sandbox.stub(process, "version").value(version);
167-
const NewLintResultCache = proxyquire("../../../lib/cli-engine/lint-result-cache.js", {
168-
"./hash": hashStub
169-
});
170-
const newLintResultCache = new NewLintResultCache(cacheFileLocation, "metadata");
166+
const versionStub = sandbox.stub(process, "version").value(version);
171167

172-
newLintResultCache.getCachedLintResults(filePath, fakeConfig);
168+
try {
169+
const NewLintResultCache = proxyquire("../../../lib/cli-engine/lint-result-cache.js", {
170+
"./hash": hashStub
171+
});
172+
const newLintResultCache = new NewLintResultCache(cacheFileLocation, "metadata");
173173

174-
assert.ok(hashStub.calledOnce);
175-
assert.ok(hashStub.calledWithMatch(version));
174+
newLintResultCache.getCachedLintResults(filePath, fakeConfig);
175+
176+
assert.ok(hashStub.calledOnce);
177+
assert.ok(hashStub.calledWithMatch(version));
178+
} finally {
179+
versionStub.restore();
180+
}
176181
});
177182
});
178183

0 commit comments

Comments
 (0)