File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -103,7 +103,9 @@ export default abstract class BaseWrapper<ElementType extends Node>
103
103
) : DOMWrapper < SVGElementTagNameMap [ K ] > [ ]
104
104
findAll < T extends Element > ( selector : string ) : DOMWrapper < T > [ ]
105
105
findAll ( selector : string ) : DOMWrapper < Element > [ ] {
106
- return this . findAllDOMElements ( selector , true ) . map ( createDOMWrapper )
106
+ const isRootNodeOfTemplate = this . getRootNodes ( ) ?. [ 0 ] === this . element
107
+ const ignoreSelf = ! isRootNodeOfTemplate || ! Reflect . get ( this , 'vm' )
108
+ return this . findAllDOMElements ( selector , ignoreSelf ) . map ( createDOMWrapper )
107
109
}
108
110
109
111
// searching by string without specifying component results in WrapperLike object
Original file line number Diff line number Diff line change @@ -357,4 +357,19 @@ describe('findAll', () => {
357
357
358
358
expect ( parent . findAll ( 'div' ) . length ) . toBe ( 3 )
359
359
} )
360
+
361
+ // https://github.com/vuejs/test-utils/issues/1233
362
+ it ( 'finds all divs with findAll' , ( ) => {
363
+ const wrapper = mount ( {
364
+ template : `
365
+ <div class="parent">
366
+ <div />
367
+ <div />
368
+ <div />
369
+ </div>
370
+ `
371
+ } )
372
+
373
+ expect ( wrapper . findAll ( 'div' ) . length ) . toBe ( 4 )
374
+ } )
360
375
} )
You can’t perform that action at this time.
0 commit comments