@@ -188,7 +188,7 @@ test('accepts custom snapshot name', () => {
188188test ( 'handles property matchers' , ( ) => {
189189 const filename = 'handle-property-matchers.test.js' ;
190190 const template = makeTemplate ( `test('handles property matchers', () => {
191- expect({createdAt: $1}).toMatchNamedSnapshot({createdAt: expect.any(Date)}, 'property-matchers' );
191+ expect({createdAt: $1}).toMatchNamedSnapshot('property-matchers', {createdAt: expect.any(Date)});
192192 });
193193 ` ) ;
194194
@@ -215,39 +215,40 @@ test('handles property matchers', () => {
215215} ) ;
216216
217217test ( 'handles invalid property matchers' , ( ) => {
218- const filename = 'handle-property-matchers.test.js' ;
218+ const filename = 'handle-invalid- property-matchers.test.js' ;
219219 {
220220 writeFiles ( TESTS_DIR , {
221221 [ filename ] : `test('invalid property matchers', () => {
222- expect({foo: 'bar'}).toMatchNamedSnapshot(null, 'null-property-matcher');
222+ expect({foo: 'bar'}).toMatchNamedSnapshot('null-property-matcher', null );
223223 });
224224 ` ,
225225 } ) ;
226226 const { stderr, exitCode} = runJest ( DIR , [ '-w=1' , '--ci=false' , filename ] ) ;
227227 expect ( stderr ) . toMatch ( 'Expected properties must be an object' ) ;
228228 expect ( exitCode ) . toBe ( 1 ) ;
229229 }
230+ } ) ;
231+
232+ test ( 'handles undefined property matchers' , ( ) => {
233+ const filename = 'handle-undefined-property-matchers.test.js' ;
230234 {
231235 writeFiles ( TESTS_DIR , {
232236 [ filename ] : `test('invalid property matchers', () => {
233- expect({foo: 'bar'}).toMatchNamedSnapshot(undefined, 'undefined-property-matcher');
237+ expect({foo: 'bar'}).toMatchNamedSnapshot('undefined-property-matcher', undefined );
234238 });
235239 ` ,
236240 } ) ;
237241 const { stderr, exitCode} = runJest ( DIR , [ '-w=1' , '--ci=false' , filename ] ) ;
238- expect ( stderr ) . toMatch ( 'Expected properties must be an object' ) ;
239- expect ( stderr ) . toMatch (
240- "To provide a snapshot name without properties: toMatchNamedSnapshot('snapshotName')" ,
241- ) ;
242- expect ( exitCode ) . toBe ( 1 ) ;
242+ expect ( stderr ) . toMatch ( '1 snapshot written' ) ;
243+ expect ( exitCode ) . toBe ( 0 ) ;
243244 }
244245} ) ;
245246
246247test ( 'handles property matchers with deep properties' , ( ) => {
247248 const filename = 'handle-property-matchers-with-name.test.js' ;
248249 const template =
249250 makeTemplate ( `test('handles property matchers with deep properties', () => {
250- expect({ user: { createdAt: $1, name: $2 }}).toMatchNamedSnapshot({ user: { createdAt: expect.any(Date), name: $2 }}, 'deep-property-matchers' );
251+ expect({ user: { createdAt: $1, name: $2 }}).toMatchNamedSnapshot('deep-property-matchers', { user: { createdAt: expect.any(Date), name: $2 }});
251252 });
252253 ` ) ;
253254
0 commit comments