Skip to content

Commit 6b0343c

Browse files
committed
refactor: improve error message
1 parent 66dcac5 commit 6b0343c

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

packages/create-instance/extend-extended-components.js

+10-6
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,16 @@ export function extendExtendedComponents (
6565
if (shouldExtendComponent) {
6666
if (logModifiedComponents) {
6767
warn(
68-
`an extended child component <${c}> has been modified ` +
69-
`to ensure it has the correct instance properties. ` +
70-
`This means it is not possible to find the component ` +
71-
`with a component selector. To find the component, ` +
72-
`you must stub it manually using the stubs mounting ` +
73-
`option.`
68+
`The child component <${c}> has been modified to ensure ` +
69+
`it is created with properties injected by Vue Test Utils. \n` +
70+
`This is because the component was created with Vue.extend, ` +
71+
`or uses the Vue Class Component decorator. \n` +
72+
`Because the component has been modified, it is not possible ` +
73+
`to find it with a component selector. To find the ` +
74+
`component, you must stub it manually using the stubs mounting ` +
75+
`option, or use a name or ref selector. \n` +
76+
`You can hide this warning by setting the Vue Test Utils ` +
77+
`config.logModifiedComponents option to false.`
7478
)
7579
}
7680
extendedComponents[c] = _Vue.extend(comp)

test/specs/mount.spec.js

+10-5
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,16 @@ describeRunIf(process.env.TEST_ENV !== 'node', 'mount', () => {
164164

165165
it('logs if component is extended', () => {
166166
const msg =
167-
`[vue-test-utils]: an extended child component <ChildComponent> ` +
168-
`has been modified to ensure it has the correct instance properties. ` +
169-
`This means it is not possible to find the component with a component ` +
170-
`selector. To find the component, you must stub it manually using the ` +
171-
`stubs mounting option.`
167+
`[vue-test-utils]: The child component <ChildComponent> has been modified to ensure ` +
168+
`it is created with properties injected by Vue Test Utils. \n` +
169+
`This is because the component was created with Vue.extend, ` +
170+
`or uses the Vue Class Component decorator. \n` +
171+
`Because the component has been modified, it is not possible ` +
172+
`to find it with a component selector. To find the ` +
173+
`component, you must stub it manually using the stubs mounting ` +
174+
`option, or use a name or ref selector. \n` +
175+
`You can hide this warning by setting the Vue Test Utils ` +
176+
`config.logModifiedComponents option to false.`
172177
const ChildComponent = Vue.extend({
173178
template: '<span />'
174179
})

0 commit comments

Comments
 (0)