Commit 313fd2d
committed
feat: allow custom
At the moment, `@vue/test-utils` doesn't allow custom `<transition>`
stubs. For example, setting:
```js
config.stubs.transition = {template: '<div />'};
```
...will still just render the default `@vue/test-utils` stub:
```html
<transition-stub appear="false" persisted="false" css="true">
```
The motivation for this change is that if you're using the `@vue/compat`
migration build, these default stubs throw up the following warning:
```
Error: (deprecation ATTR_FALSE_VALUE) Attribute "persisted" with v-bind value `false` will render persisted="false" instead of removing it in Vue 3. To remove the attribute, use `null` or `undefined` instead. If the usage is intended, you can disable the compat behavior and suppress this warning with:
configureCompat({ ATTR_FALSE_VALUE: false })
Details: https://v3-migration.vuejs.org/breaking-changes/attribute-coercion.html
at <Transition>
```
Since `persisted` isn't actually a [boolean HTML attribute][1], and is
actually a [prop][2], we want to ignore this false positive, but don't
want to disable this warning everywhere (so we can catch *actual*
errors).
In order to clean up our test warnings, we would like to use a custom
`<transition>` stub, which doesn't have these props. This change tweaks
the `transition` stubbing logic, and only creates the default stub if
`transition === true`. If it's any other truthy value, it falls back to
"normal" stubbing behaviour.
[1]: https://html.spec.whatwg.org/multipage/indices.html#attributes-3
[2]: https://github.com/vuejs/core/blob/b775b71c788499ec7ee58bc2cf4cd04ed388e072/packages/runtime-core/src/components/BaseTransition.ts#L37<transition> stubs1 parent 211afd8 commit 313fd2d
File tree
2 files changed
+25
-5
lines changed- src/vnodeTransformers
- tests/mountingOptions
2 files changed
+25
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
86 | 88 | | |
87 | 89 | | |
88 | 90 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
482 | 482 | | |
483 | 483 | | |
484 | 484 | | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
485 | 503 | | |
486 | 504 | | |
487 | 505 | | |
| |||
0 commit comments