Skip to content

Commit a249065

Browse files
authored
Remove type condition (#1558)
In cases where the empty object is already set as default in the config: See: `stubs`, `mocks` and `methods` https://github.com/vuejs/vue-test-utils/blob/dev/packages/test-utils/src/config.js The ? is not necessary. In this case, we can import the config and we will not be forced to check the existence of attributes: ``` import { config } from '@vue/test-utils'; if (config.mocks) { config.mocks.i18n = { t: jest.fn() }; config.mocks.$t = jest.fn(); } ``` and use directly ``` import { config } from '@vue/test-utils'; config.mocks.i18n = { t: jest.fn() }; config.mocks.$t = jest.fn(); ```
1 parent 2858f24 commit a249065

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

packages/test-utils/types/index.d.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,9 @@ type ShallowMountOptions<V extends Vue> = MountOptions<V>
160160
type ThisTypedShallowMountOptions<V extends Vue> = ShallowMountOptions<V> & ThisType<V>
161161

162162
interface VueTestUtilsConfigOptions {
163-
stubs?: Record<string, Component | boolean | string>
164-
mocks?: Record<string, any>
165-
methods?: Record<string, Function>
163+
stubs: Record<string, Component | boolean | string>
164+
mocks: Record<string, any>
165+
methods: Record<string, Function>
166166
provide?: Record<string, any>,
167167
silent?: Boolean,
168168
showDeprecationWarnings?: boolean

0 commit comments

Comments
 (0)