@@ -52,6 +52,9 @@ export const SnapshotPlugin: ChaiPlugin = (chai, utils) => {
5252 chai . Assertion . prototype ,
5353 key ,
5454 function ( this : Record < string , unknown > , properties ?: object , message ?: string ) {
55+ const isNot = utils . flag ( this , 'negate' )
56+ if ( isNot )
57+ throw new Error ( `${ key } cannot be used with "not"` )
5558 const expected = utils . flag ( this , 'object' )
5659 const test = utils . flag ( this , 'vitest-test' )
5760 if ( typeof properties === 'string' && typeof message === 'undefined' ) {
@@ -75,6 +78,9 @@ export const SnapshotPlugin: ChaiPlugin = (chai, utils) => {
7578 chai . Assertion . prototype ,
7679 'toMatchFileSnapshot' ,
7780 function ( this : Record < string , unknown > , file : string , message ?: string ) {
81+ const isNot = utils . flag ( this , 'negate' )
82+ if ( isNot )
83+ throw new Error ( 'toMatchFileSnapshot cannot be used with "not"' )
7884 const expected = utils . flag ( this , 'object' )
7985 const test = utils . flag ( this , 'vitest-test' ) as Test
8086 const errorMessage = utils . flag ( this , 'message' )
@@ -98,6 +104,9 @@ export const SnapshotPlugin: ChaiPlugin = (chai, utils) => {
98104 chai . Assertion . prototype ,
99105 'toMatchInlineSnapshot' ,
100106 function __INLINE_SNAPSHOT__ ( this : Record < string , unknown > , properties ?: object , inlineSnapshot ?: string , message ?: string ) {
107+ const isNot = utils . flag ( this , 'negate' )
108+ if ( isNot )
109+ throw new Error ( 'toMatchInlineSnapshot cannot be used with "not"' )
101110 const test = utils . flag ( this , 'vitest-test' )
102111 const isInsideEach = test && ( test . each || test . suite ?. each )
103112 if ( isInsideEach )
@@ -129,6 +138,9 @@ export const SnapshotPlugin: ChaiPlugin = (chai, utils) => {
129138 chai . Assertion . prototype ,
130139 'toThrowErrorMatchingSnapshot' ,
131140 function ( this : Record < string , unknown > , message ?: string ) {
141+ const isNot = utils . flag ( this , 'negate' )
142+ if ( isNot )
143+ throw new Error ( 'toThrowErrorMatchingSnapshot cannot be used with "not"' )
132144 const expected = utils . flag ( this , 'object' )
133145 const test = utils . flag ( this , 'vitest-test' )
134146 const promise = utils . flag ( this , 'promise' ) as string | undefined
@@ -145,6 +157,9 @@ export const SnapshotPlugin: ChaiPlugin = (chai, utils) => {
145157 chai . Assertion . prototype ,
146158 'toThrowErrorMatchingInlineSnapshot' ,
147159 function __INLINE_SNAPSHOT__ ( this : Record < string , unknown > , inlineSnapshot : string , message : string ) {
160+ const isNot = utils . flag ( this , 'negate' )
161+ if ( isNot )
162+ throw new Error ( 'toThrowErrorMatchingInlineSnapshot cannot be used with "not"' )
148163 const test = utils . flag ( this , 'vitest-test' )
149164 const isInsideEach = test && ( test . each || test . suite ?. each )
150165 if ( isInsideEach )
0 commit comments