@@ -52,6 +52,9 @@ export const SnapshotPlugin: ChaiPlugin = (chai, utils) => {
52
52
chai . Assertion . prototype ,
53
53
key ,
54
54
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"` )
55
58
const expected = utils . flag ( this , 'object' )
56
59
const test = utils . flag ( this , 'vitest-test' )
57
60
if ( typeof properties === 'string' && typeof message === 'undefined' ) {
@@ -75,6 +78,9 @@ export const SnapshotPlugin: ChaiPlugin = (chai, utils) => {
75
78
chai . Assertion . prototype ,
76
79
'toMatchFileSnapshot' ,
77
80
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"' )
78
84
const expected = utils . flag ( this , 'object' )
79
85
const test = utils . flag ( this , 'vitest-test' ) as Test
80
86
const errorMessage = utils . flag ( this , 'message' )
@@ -98,6 +104,9 @@ export const SnapshotPlugin: ChaiPlugin = (chai, utils) => {
98
104
chai . Assertion . prototype ,
99
105
'toMatchInlineSnapshot' ,
100
106
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"' )
101
110
const test = utils . flag ( this , 'vitest-test' )
102
111
const isInsideEach = test && ( test . each || test . suite ?. each )
103
112
if ( isInsideEach )
@@ -129,6 +138,9 @@ export const SnapshotPlugin: ChaiPlugin = (chai, utils) => {
129
138
chai . Assertion . prototype ,
130
139
'toThrowErrorMatchingSnapshot' ,
131
140
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"' )
132
144
const expected = utils . flag ( this , 'object' )
133
145
const test = utils . flag ( this , 'vitest-test' )
134
146
const promise = utils . flag ( this , 'promise' ) as string | undefined
@@ -145,6 +157,9 @@ export const SnapshotPlugin: ChaiPlugin = (chai, utils) => {
145
157
chai . Assertion . prototype ,
146
158
'toThrowErrorMatchingInlineSnapshot' ,
147
159
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"' )
148
163
const test = utils . flag ( this , 'vitest-test' )
149
164
const isInsideEach = test && ( test . each || test . suite ?. each )
150
165
if ( isInsideEach )
0 commit comments