File tree Expand file tree Collapse file tree 2 files changed +10
-7
lines changed Expand file tree Collapse file tree 2 files changed +10
-7
lines changed Original file line number Diff line number Diff line change 9
9
} from '../role-helpers'
10
10
import { wrapAllByQueryWithSuggestion } from '../query-helpers'
11
11
import { checkContainerType } from '../helpers'
12
- import { prettyDOM } from '../pretty-dom'
13
12
import {
14
13
buildQueries ,
15
14
fuzzyMatches ,
@@ -108,11 +107,8 @@ function queryAllByRole(
108
107
} )
109
108
}
110
109
111
- const getMultipleError = ( { elements} , role ) => {
112
- const suggestions = elements . map ( element => prettyDOM ( element ) ) . join ( '\n' )
113
-
114
- return `Found multiple elements with the role "${ role } "
115
- ${ suggestions } `
110
+ const getMultipleError = ( c , role ) => {
111
+ return `Found multiple elements with the role "${ role } "`
116
112
}
117
113
118
114
const getMissingError = (
Original file line number Diff line number Diff line change
1
+ import { prettyDOM } from './pretty-dom'
1
2
import { getSuggestedQuery } from './suggestions'
2
3
import { fuzzyMatches , matches , makeNormalizer } from './matches'
3
4
import { waitFor } from './wait-for'
@@ -45,8 +46,14 @@ function makeSingleQuery(allQuery, getMultipleError) {
45
46
return ( container , ...args ) => {
46
47
const els = allQuery ( container , ...args )
47
48
if ( els . length > 1 ) {
49
+ const elementStrings = els . map ( element => prettyDOM ( element ) ) . join ( '\n\n' )
50
+
48
51
throw getMultipleElementsFoundError (
49
- getMultipleError ( { container, elements : els } , ...args ) ,
52
+ `${ getMultipleError ( container , ...args ) }
53
+
54
+ Here are the matching elements:
55
+
56
+ ${ elementStrings } `,
50
57
container ,
51
58
)
52
59
}
You can’t perform that action at this time.
0 commit comments