Skip to content

Commit 735e503

Browse files
committed
edit e2e testing
1 parent 6b1a6ed commit 735e503

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

e2e/__tests__/toMatchNamedSnapshot.test.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ test('accepts custom snapshot name', () => {
188188
test('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

217217
test('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

246247
test('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

e2e/__tests__/toMatchNamedSnapshotWithRetries.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,14 @@ test('works with a single snapshot', () => {
6161
test('works when multiple tests have snapshots but only one of them failed multiple times', () => {
6262
const filename = 'basic-support.test.js';
6363
const template = makeTemplate(`
64-
test('passing snapshots', () => expect('foo').toMatchNamedSnapshot());
64+
test('passing snapshots', () => expect('foo').toMatchNamedSnapshot('passing snapshots'));
6565
describe('with retries', () => {
6666
let index = 0;
6767
afterEach(() => {
6868
index += 1;
6969
});
7070
jest.retryTimes($2);
71-
test('snapshots', () => expect($1).toMatchNamedSnapshot());
71+
test('snapshots', () => expect($1).toMatchNamedSnapshot('with retries'));
7272
});
7373
`);
7474

0 commit comments

Comments
 (0)