Skip to content

Commit 57dd54f

Browse files
committed
refactor(src): ensure expect function failure does not crash context check
1 parent e27117a commit 57dd54f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/plugin-tester.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,16 @@ function pluginTester(options: PluginTesterOptions = {}) {
115115
const globalContextHasDescribeFn =
116116
'describe' in globalThis && typeof describe == 'function';
117117

118-
const globalContextExpectFnHasToMatchSnapshot = globalContextHasExpectFn
118+
const globalContextExpectFnHasToMatchSnapshot = (() => {
119+
try {
120+
return globalContextHasExpectFn
119121
? typeof expect(undefined)?.toMatchSnapshot == 'function'
120122
: false;
123+
} catch {
124+
/* istanbul ignore next */
125+
return false;
126+
}
127+
})();
121128

122129
const globalContextTestFnHasSkip = globalContextHasTestFn
123130
? typeof it.skip == 'function'

0 commit comments

Comments
 (0)