diff --git a/packages/shared/util.js b/packages/shared/util.js index 2d50152fa..ecec28da6 100644 --- a/packages/shared/util.js +++ b/packages/shared/util.js @@ -102,7 +102,7 @@ export function nextTick(): Promise { export function warnDeprecated(method: string, fallback: string = '') { if (!config.showDeprecationWarnings) return - let msg = `${method} is deprecated and will removed in the next major version` + let msg = `${method} is deprecated and will be removed in the next major version` if (fallback) msg += ` ${fallback}` warn(msg) } diff --git a/packages/test-utils/src/wrapper.js b/packages/test-utils/src/wrapper.js index 3ae6a0e42..ed950a8c9 100644 --- a/packages/test-utils/src/wrapper.js +++ b/packages/test-utils/src/wrapper.js @@ -142,7 +142,7 @@ export default class Wrapper implements BaseWrapper { * Calls destroy on vm */ destroy(): void { - if (!this.isVueInstance() && !this.isFunctionalComponent) { + if (!this.vm && !this.isFunctionalComponent) { throwError( `wrapper.destroy() can only be called on a Vue instance or ` + `functional component.` @@ -153,7 +153,7 @@ export default class Wrapper implements BaseWrapper { this.element.parentNode.removeChild(this.element) } - if (this.isVueInstance()) { + if (this.vm) { // $FlowIgnore this.vm.$destroy() throwIfInstancesThrew(this.vm) @@ -370,7 +370,7 @@ export default class Wrapper implements BaseWrapper { */ isVisible(): boolean { warnDeprecated( - 'isEmpty', + 'isVisible', `Consider a custom matcher such as those provided in jest-dom: https://github.com/testing-library/jest-dom#tobevisible` ) let element = this.element @@ -428,7 +428,7 @@ export default class Wrapper implements BaseWrapper { overview(): void { warnDeprecated(`overview`) - if (!this.isVueInstance()) { + if (!this.vm) { throwError(`wrapper.overview() can only be called on a Vue instance`) } @@ -530,11 +530,6 @@ export default class Wrapper implements BaseWrapper { * @deprecated */ setChecked(checked: boolean = true): Promise<*> { - warnDeprecated( - `setChecked`, - 'When you migrate to VTU 2, use setValue instead.' - ) - if (typeof checked !== 'boolean') { throwError('wrapper.setChecked() must be passed a boolean') } @@ -582,11 +577,6 @@ export default class Wrapper implements BaseWrapper { * @deprecated */ setSelected(): Promise { - warnDeprecated( - `setSelected`, - 'When you migrate to VTU 2, use setValue instead.' - ) - const tagName = this.element.tagName if (tagName === 'SELECT') { @@ -642,7 +632,7 @@ export default class Wrapper implements BaseWrapper { setMethods(methods: Object): void { warnDeprecated(`setMethods`) - if (!this.isVueInstance()) { + if (!this.vm) { throwError(`wrapper.setMethods() can only be called on a Vue instance`) } Object.keys(methods).forEach(key => { diff --git a/packages/test-utils/types/index.d.ts b/packages/test-utils/types/index.d.ts index a553197b7..06a05f545 100644 --- a/packages/test-utils/types/index.d.ts +++ b/packages/test-utils/types/index.d.ts @@ -136,12 +136,12 @@ export interface WrapperArray extends BaseWrapper { } interface WrapperOptions { - attachTo?: Element | string attachedToDocument?: boolean } interface MountOptions extends ComponentOptions { attachToDocument?: boolean + attachTo?: Element | string context?: VNodeData localVue?: typeof Vue mocks?: object | false diff --git a/packages/test-utils/types/test/mount.ts b/packages/test-utils/types/test/mount.ts index c3c3fdef4..4a92c0ca9 100644 --- a/packages/test-utils/types/test/mount.ts +++ b/packages/test-utils/types/test/mount.ts @@ -28,6 +28,7 @@ mount(ClassComponent, { mocks: { $store: store }, + attachTo: '#el', parentComponent: normalOptions, slots: { default: `
Foo
`, @@ -57,6 +58,7 @@ mount(functionalOptions, { context: { props: { foo: 'test' } }, + attachTo: document.createElement('div'), stubs: ['child'] }) @@ -100,6 +102,7 @@ config.provide['foo'] = { bar: {} } config.silent = true +config.showDeprecationWarnings = false // Check we can use default export VueTestUtils.config.silent = false