Skip to content

Commit e957f2d

Browse files
Make snapshot of error instead of partial match
1 parent b567f10 commit e957f2d

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,31 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3+
exports[`getByLabelText query will print the playground link when enabled in the config 1`] = `
4+
"Unable to find a label with the text of: TEST QUERY
5+
6+
<body>
7+
<div>
8+
Hello
9+
</div>
10+
</body>
11+
12+
Open this DOM in the Testing-Library Playground:
13+
https://testing-playground.com/#markup=DwEwlgbgfAEgpgGwQe2AenNIA"
14+
`;
15+
316
exports[`getByLabelText query will throw the custom error returned by config.getElementError 1`] = `"My custom error: Unable to find a label with the text of: TEST QUERY"`;
417

18+
exports[`getByText query will print the playground link when enabled in the config 1`] = `
19+
"Unable to find an element with the text: TEST QUERY. This could be because the text is broken up by multiple elements. In this case, you can provide a function for your text matcher to make your matcher more flexible.
20+
21+
<body>
22+
<div>
23+
Hello
24+
</div>
25+
</body>
26+
27+
Open this DOM in the Testing-Library Playground:
28+
https://testing-playground.com/#markup=DwEwlgbgfAEgpgGwQe2AenNIA"
29+
`;
30+
531
exports[`getByText query will throw the custom error returned by config.getElementError 1`] = `"My custom error: Unable to find an element with the text: TEST QUERY. This could be because the text is broken up by multiple elements. In this case, you can provide a function for your text matcher to make your matcher more flexible."`;

src/__tests__/get-by-errors.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ test.each([['getByText'], ['getByLabelText']])(
102102
query => {
103103
configure({printPlaygroundLink: true})
104104
document.body.innerHTML = '<div>Hello</div>'
105-
expect(() => screen[query]('TEST QUERY')).toThrow(/playground/i)
105+
expect(() => screen[query]('TEST QUERY')).toThrowErrorMatchingSnapshot()
106106
},
107107
)
108108

0 commit comments

Comments
 (0)