You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/__tests__/helpers.js
+40-34Lines changed: 40 additions & 34 deletions
Original file line number
Diff line number
Diff line change
@@ -5,10 +5,6 @@ import {
5
5
runWithRealTimers,
6
6
}from'../helpers'
7
7
8
-
constglobalObj=typeofwindow==='undefined' ? global : window
9
-
10
-
afterEach(()=>jest.useRealTimers())
11
-
12
8
test('returns global document if exists',()=>{
13
9
expect(getDocument()).toBe(document)
14
10
})
@@ -21,6 +17,11 @@ describe('window retrieval throws when given something other than a node', () =>
21
17
`"It looks like you passed a Promise object instead of a DOM node. Did you do something like \`fireEvent.click(screen.findBy...\` when you meant to use a \`getBy\` query \`fireEvent.click(screen.getBy...\`, or await the findBy query \`fireEvent.click(await screen.findBy...\`?"`,
`"It looks like you passed an Array instead of a DOM node. Did you do something like \`fireEvent.click(screen.getAllBy...\` when you meant to use a \`getBy\` query \`fireEvent.click(screen.getBy...\`?"`,
`"Unable to find the \\"window\\" object for the given node. Please file an issue with the code that's causing you to see this error: https://github.com/testing-library/dom-testing-library/issues/new"`,
// we only run our tests in node, and setImmediate is supported in node.
56
56
// istanbul ignore next
@@ -92,6 +92,10 @@ function getWindowFromNode(node) {
92
92
thrownewError(
93
93
`It looks like you passed a Promise object instead of a DOM node. Did you do something like \`fireEvent.click(screen.findBy...\` when you meant to use a \`getBy\` query \`fireEvent.click(screen.getBy...\`, or await the findBy query \`fireEvent.click(await screen.findBy...\`?`,
94
94
)
95
+
}elseif(Array.isArray(node)){
96
+
thrownewError(
97
+
`It looks like you passed an Array instead of a DOM node. Did you do something like \`fireEvent.click(screen.getAllBy...\` when you meant to use a \`getBy\` query \`fireEvent.click(screen.getBy...\`?`,
98
+
)
95
99
}else{
96
100
// The user passed something unusual to a calling function
0 commit comments