File tree 1 file changed +56
-0
lines changed 1 file changed +56
-0
lines changed Original file line number Diff line number Diff line change @@ -353,6 +353,62 @@ test('mocks a vuex store', async () => {
353
353
})
354
354
```
355
355
356
+ ### ` global.stubs `
357
+
358
+ Stubs a component for all Vue Instances.
359
+
360
+ ` Component.vue ` :
361
+
362
+ ``` vue
363
+ <template>
364
+ <div><foo/></div>
365
+ </template>
366
+
367
+ <script>
368
+ import Foo from '@/Foo.vue'
369
+ export default {
370
+ components: { Foo }
371
+ }
372
+ </script>
373
+ ```
374
+
375
+ ` Component.spec.js ` :
376
+
377
+ ``` js
378
+ test (' stubs a component using simple Array' , () => {
379
+ const wrapper = mount (Component, {
380
+ global: {
381
+ stubs: [' Foo' ]
382
+ }
383
+ })
384
+
385
+ expect (wrapper .html ()).toEqual (' <div><foo-stub></div>' )
386
+ })
387
+
388
+ test (' stubs a component using an Object boolean syntax' , () => {
389
+ const wrapper = mount (Component, {
390
+ global: {
391
+ stubs: { Foo: true }
392
+ }
393
+ })
394
+
395
+ expect (wrapper .html ()).toEqual (' <div><foo-stub></div>' )
396
+ })
397
+
398
+ test (' stubs a component using a custom component' , () => {
399
+ const FooMock = {
400
+ name: ' Foo' ,
401
+ template: ' FakeFoo'
402
+ }
403
+ const wrapper = mount (Component, {
404
+ global: {
405
+ stubs: { Foo: FooMock }
406
+ }
407
+ })
408
+
409
+ expect (wrapper .html ()).toEqual (' <div>FakeFoo</div>' )
410
+ })
411
+ ```
356
412
357
413
## Wrapper
358
414
You can’t perform that action at this time.
0 commit comments