Skip to content

Commit ef613de

Browse files
authored
refactor: remove sync mode (#1141)
BREAKING CHANGE: * Remove `sync` mode * Remove TransitionStub * Remove Transition
1 parent 36adbf3 commit ef613de

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+138
-814
lines changed

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"babel-plugin-syntax-jsx": "^6.18.0",
3737
"babel-plugin-transform-decorators-legacy": "^1.3.4",
3838
"babel-plugin-transform-vue-jsx": "^3.7.0",
39-
"babel-polyfill": "^6.23.0",
39+
"babel-polyfill": "^6.26.0",
4040
"babel-preset-env": "^1.6.0",
4141
"babel-preset-flow-vue": "^1.0.0",
4242
"babel-preset-stage-2": "^6.24.1",

Diff for: packages/create-instance/extract-instance-options.js

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ const MOUNTING_OPTIONS = [
1111
'attrs',
1212
'listeners',
1313
'propsData',
14-
'sync',
1514
'shouldProxy'
1615
]
1716

Diff for: packages/server-test-utils/types/index.d.ts

-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ interface MountOptions<V extends Vue> extends ComponentOptions<V> {
3636
stubs?: Stubs,
3737
attrs?: Record<string, string>
3838
listeners?: Record<string, Function | Function[]>
39-
sync?: boolean
4039
}
4140

4241
type ThisTypedMountOptions<V extends Vue> = MountOptions<V> & ThisType<V>

Diff for: packages/server-test-utils/types/test/renderToString.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ render(
1212
attachToDocument: true,
1313
scopedSlots: {
1414
foo: `<div>Foo</div>`
15-
},
16-
sync: false
15+
}
1716
}
1817
)
1918

Diff for: packages/shared/consts.js

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ export const COMPONENT_SELECTOR = 'COMPONENT_SELECTOR'
66
export const REF_SELECTOR = 'REF_SELECTOR'
77
export const DOM_SELECTOR = 'DOM_SELECTOR'
88
export const INVALID_SELECTOR = 'INVALID_SELECTOR'
9-
export const COMPAT_SYNC_MODE = 'COMPAT_SYNC_MODE'
109

1110
export const VUE_VERSION = Number(
1211
`${Vue.version.split('.')[0]}.${Vue.version.split('.')[1]}`

Diff for: packages/shared/merge-options.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ export function mergeOptions(
4141
provide: normalizeProvide(provide),
4242
stubs,
4343
mocks,
44-
methods,
45-
sync: !!(options.sync || options.sync === undefined)
44+
methods
4645
}
4746
}

Diff for: packages/test-utils/src/components/TransitionGroupStub.js

-10
This file was deleted.

Diff for: packages/test-utils/src/components/TransitionStub.js

-147
This file was deleted.

Diff for: packages/test-utils/src/error-wrapper.js

-7
Original file line numberDiff line numberDiff line change
@@ -249,13 +249,6 @@ export default class ErrorWrapper implements BaseWrapper {
249249
)
250250
}
251251

252-
update(): void {
253-
throwError(
254-
`update has been removed from vue-test-utils.` +
255-
`All updates are now synchronous by default`
256-
)
257-
}
258-
259252
destroy(): void {
260253
throwError(
261254
`find did not return ${

Diff for: packages/test-utils/src/index.js

-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import shallowMount from './shallow-mount'
22
import mount from './mount'
33
import createLocalVue from './create-local-vue'
4-
import TransitionStub from './components/TransitionStub'
5-
import TransitionGroupStub from './components/TransitionGroupStub'
64
import RouterLinkStub from './components/RouterLinkStub'
75
import createWrapper from './create-wrapper'
86
import Wrapper from './wrapper'
@@ -25,8 +23,6 @@ export default {
2523
mount,
2624
shallow,
2725
shallowMount,
28-
TransitionStub,
29-
TransitionGroupStub,
3026
RouterLinkStub,
3127
Wrapper,
3228
WrapperArray

Diff for: packages/test-utils/src/mount.js

+1-62
Original file line numberDiff line numberDiff line change
@@ -7,63 +7,11 @@ import config from './config'
77
import warnIfNoWindow from './warn-if-no-window'
88
import createWrapper from './create-wrapper'
99
import createLocalVue from './create-local-vue'
10-
import { warn } from 'shared/util'
11-
import semver from 'semver'
12-
import { COMPAT_SYNC_MODE } from 'shared/consts'
1310
import { validateOptions } from 'shared/validate-options'
14-
import TransitionGroupStub from './components/TransitionGroupStub'
15-
import TransitionStub from './components/TransitionStub'
1611

1712
Vue.config.productionTip = false
1813
Vue.config.devtools = false
1914

20-
function getSyncOption(syncOption) {
21-
if (syncOption === false) {
22-
Vue.config.async = true
23-
return false
24-
}
25-
if (semver.lt(Vue.version, '2.5.18')) {
26-
warn(
27-
`Vue Test Utils runs in sync mode by default. Due to bugs, sync mode ` +
28-
`requires Vue > 2.5.18. In Vue Test Utils 1.0 sync mode will only be ` +
29-
`supported with Vue 2.5.18+ running in development mode. If you are ` +
30-
`unable to upgrade, you should rewrite your tests to run asynchronously` +
31-
`you can do this by setting the sync mounting option to false.`
32-
)
33-
return COMPAT_SYNC_MODE
34-
}
35-
36-
if (typeof Vue.config.async === 'undefined') {
37-
warn(
38-
`Sync mode only works when Vue runs in dev mode. ` +
39-
`Please set Vue to run in dev mode, or set sync to false`
40-
)
41-
}
42-
43-
Vue.config.async = false
44-
return true
45-
}
46-
47-
function addTransitionStubs(options) {
48-
if (config.stubs === false) {
49-
return
50-
}
51-
if (
52-
options.stubs &&
53-
options.stubs.transition !== false &&
54-
!options.stubs.transition
55-
) {
56-
options.stubs.transition = TransitionStub
57-
}
58-
if (
59-
options.stubs &&
60-
options.stubs['transition-group'] !== false &&
61-
!options.stubs['transition-group']
62-
) {
63-
options.stubs['transition-group'] = TransitionGroupStub
64-
}
65-
}
66-
6715
export default function mount(component, options = {}) {
6816
warnIfNoWindow()
6917

@@ -72,17 +20,9 @@ export default function mount(component, options = {}) {
7220
const _Vue = createLocalVue(options.localVue)
7321

7422
const mergedOptions = mergeOptions(options, config)
75-
const sync = getSyncOption(mergedOptions.sync)
7623

7724
validateOptions(mergedOptions, component)
7825

79-
// Stub transition and transition-group if in compat sync mode to keep old
80-
// behavior
81-
// TODO: Remove when compat sync mode is removed
82-
if (sync === COMPAT_SYNC_MODE) {
83-
addTransitionStubs(mergedOptions)
84-
}
85-
8626
const parentVm = createInstance(component, mergedOptions, _Vue)
8727

8828
const el = options.attachToDocument ? createElement() : undefined
@@ -93,8 +33,7 @@ export default function mount(component, options = {}) {
9333
throwIfInstancesThrew(vm)
9434

9535
const wrapperOptions = {
96-
attachedToDocument: !!mergedOptions.attachToDocument,
97-
sync
36+
attachedToDocument: !!mergedOptions.attachToDocument
9837
}
9938

10039
const root = parentVm.$options._isFunctionalContainer

Diff for: packages/test-utils/src/order-watchers.js

-35
This file was deleted.

0 commit comments

Comments
 (0)