Skip to content

Conversation

dobromir-hristov
Copy link
Contributor

@dobromir-hristov dobromir-hristov commented Apr 11, 2020

This PR adds a global config object, to allow users to add global Mixins, mocks or others for all Test files.

Closes #35

@lmiller1990
Copy link
Member

@dobromir-hristov
Copy link
Contributor Author

Theoretically it is, the PR is just to have feature parity with the Vue config API.

@lmiller1990
Copy link
Member

let's make this global.

import { config } from '@vue/test-utils'

config.mocks = ...

This is esp. useful for mocking $t

Copy link
Member

@lmiller1990 lmiller1990 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one comment about allowing passing globalProperties to as a mounting option - not sure if it makes sense (not something we support in beta iirc). If something is global, it should be applied on all components - what's the use case to override it locally?

looking good, lodash makes things so easy 🎉

@dobromir-hristov dobromir-hristov changed the title Add globalProperties config to global Add global configuration settings Apr 16, 2020
@dobromir-hristov dobromir-hristov force-pushed the feat/add-global-properties branch from d37a814 to 2ec6d17 Compare April 16, 2020 19:35
Copy link
Member

@lmiller1990 lmiller1990 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once the conflict is gone, happy to merge this.

configGlobal = {},
mountGlobal = {}
): GlobalMountOptions {
return mergeWith({}, configGlobal, mountGlobal, (objValue, srcValue, key) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 🙌

import { GlobalMountOptions } from './types'

export const config: { global: GlobalMountOptions } = {
global: {}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I add each of the properties here, with an empty array or object?

return { ...objValue, ...srcValue }
case 'plugins':
case 'mixins':
return [...(objValue || []), ...(srcValue || [])].filter(Boolean)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will not overwrite a plugin or mixin if defined globally first, it will concat them. That should be fine though?

@dobromir-hristov dobromir-hristov merged commit 66d4d44 into master Apr 20, 2020
@dobromir-hristov dobromir-hristov deleted the feat/add-global-properties branch April 20, 2020 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add global configuration settings

3 participants