Skip to content

Commit 2be0f80

Browse files
Merge branch 'vuejs:dev' into translate-to-portuguese
2 parents fa6ee7d + 0d4543d commit 2be0f80

File tree

11 files changed

+314
-298
lines changed

11 files changed

+314
-298
lines changed

Diff for: docs/installation/using-with-jest.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ The plugin pulls all required dependencies (including jest), creates a `jest.con
1717
After that, all you need to do is to install Vue Test Utils.
1818

1919
```bash
20-
$ npm install --save-dev @vue/test-utils
20+
$ npm install --save-dev @vue/test-utils@legacy
2121
```
2222

2323
### Manual installation
2424

2525
After setting up Jest, the first thing to do is to install Vue Test Utils and [`vue-jest`](https://github.com/vuejs/vue-jest) to process Single-File Components:
2626

2727
```bash
28-
$ npm install --save-dev @vue/test-utils vue-jest
28+
$ npm install --save-dev @vue/test-utils@legacy vue-jest
2929
```
3030

3131
Then, you need to tell Jest to transform `.vue` files using `vue-jest`. You can do so by adding the following configuration in `package.json` or in a standalone [Jest config file](https://jestjs.io/docs/en/configuration):

Diff for: lerna.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
],
66
"npmClient": "yarn",
77
"useWorkspaces": true,
8-
"version": "1.3.3"
8+
"version": "1.3.5"
99
}

Diff for: packages/server-test-utils/dist/vue-server-test-utils.js

+60-57
Original file line numberDiff line numberDiff line change
@@ -1750,7 +1750,7 @@ function isVueComponent(c) {
17501750
return true
17511751
}
17521752

1753-
if (c === null || typeof c !== 'object') {
1753+
if (!isPlainObject(c)) {
17541754
return false
17551755
}
17561756

@@ -1780,8 +1780,8 @@ function componentNeedsCompiling(component) {
17801780

17811781
function isRefSelector(refOptionsObject) {
17821782
if (
1783-
typeof refOptionsObject !== 'object' ||
1784-
Object.keys(refOptionsObject || {}).length !== 1
1783+
!isPlainObject(refOptionsObject) ||
1784+
keys$1(refOptionsObject || {}).length !== 1
17851785
) {
17861786
return false
17871787
}
@@ -1790,7 +1790,7 @@ function isRefSelector(refOptionsObject) {
17901790
}
17911791

17921792
function isNameSelector(nameOptionsObject) {
1793-
if (typeof nameOptionsObject !== 'object' || nameOptionsObject === null) {
1793+
if (!isPlainObject(nameOptionsObject)) {
17941794
return false
17951795
}
17961796

@@ -1806,7 +1806,7 @@ function isDynamicComponent(c) {
18061806
}
18071807

18081808
function isComponentOptions(c) {
1809-
return c !== null && typeof c === 'object' && (c.template || c.render)
1809+
return isPlainObject(c) && (c.template || c.render)
18101810
}
18111811

18121812
function isFunctionalComponent(c) {
@@ -1848,10 +1848,10 @@ function makeMap(str, expectsLowerCase) {
18481848
map[list[i]] = true;
18491849
}
18501850
return expectsLowerCase
1851-
? function(val) {
1851+
? function (val) {
18521852
return map[val.toLowerCase()]
18531853
}
1854-
: function(val) {
1854+
: function (val) {
18551855
return map[val]
18561856
}
18571857
}
@@ -1923,7 +1923,7 @@ function vmCtorMatches(vm, component) {
19231923
}
19241924

19251925
if (component.functional) {
1926-
return Object.keys(vm._Ctor || {}).some(function (c) {
1926+
return keys$1(vm._Ctor || {}).some(function (c) {
19271927
return component === vm._Ctor[c].extendOptions
19281928
})
19291929
}
@@ -2105,7 +2105,7 @@ function getOption(option, config) {
21052105
if (option === false) {
21062106
return false
21072107
}
2108-
if (option || (config && Object.keys(config).length > 0)) {
2108+
if (option || (config && keys$1(config).length > 0)) {
21092109
if (option instanceof Function) {
21102110
return option
21112111
}
@@ -2129,7 +2129,7 @@ function mergeOptions(
21292129
) {
21302130
var mocks = (getOption(options.mocks, config.mocks));
21312131
var methods = (getOption(options.methods, config.methods));
2132-
if (methods && Object.keys(methods).length) {
2132+
if (methods && keys$1(methods).length) {
21332133
warnDeprecated(
21342134
'overwriting methods via the `methods` property',
21352135
'There is no clear migration path for the `methods` property - Vue does not support arbitrarily replacement of methods, nor should VTU. To stub a complex method extract it from the component and test it in isolation. Otherwise, the suggestion is to rethink those tests'
@@ -8084,7 +8084,10 @@ ErrorWrapper.prototype.destroy = function destroy () {
80848084
*/
80858085

80868086
function isStyleVisible(element) {
8087-
if (!(element instanceof HTMLElement) && !(element instanceof SVGElement)) {
8087+
if (
8088+
!(element instanceof window.HTMLElement) &&
8089+
!(element instanceof window.SVGElement)
8090+
) {
80888091
return false
80898092
}
80908093

@@ -8124,14 +8127,14 @@ function isElementVisible(element, previousElement) {
81248127
}
81258128

81268129
function recursivelySetData(vm, target, data) {
8127-
Object.keys(data).forEach(function (key) {
8130+
keys$1(data).forEach(function (key) {
81288131
var val = data[key];
81298132
var targetVal = target[key];
81308133

81318134
if (
81328135
isPlainObject(val) &&
81338136
isPlainObject(targetVal) &&
8134-
Object.keys(val).length > 0
8137+
keys$1(val).length > 0
81358138
) {
81368139
recursivelySetData(vm, targetVal, val);
81378140
} else {
@@ -9379,10 +9382,10 @@ var w3cKeys = {
93799382
esc: 'Esc',
93809383
escape: 'Escape',
93819384
space: ' ',
9382-
up: 'Up',
9383-
left: 'Left',
9384-
right: 'Right',
9385-
down: 'Down',
9385+
up: 'ArrowUp',
9386+
left: 'ArrowLeft',
9387+
right: 'ArrowRight',
9388+
down: 'ArrowDown',
93869389
end: 'End',
93879390
home: 'Home',
93889391
backspace: 'Backspace',
@@ -9467,7 +9470,7 @@ function createDOMEvent(type, options) {
94679470
: createOldEvent(eventParams);
94689471

94699472
var eventPrototype = Object.getPrototypeOf(event);
9470-
Object.keys(options || {}).forEach(function (key) {
9473+
keys$1(options || {}).forEach(function (key) {
94719474
var propertyDescriptor = Object.getOwnPropertyDescriptor(
94729475
eventPrototype,
94739476
key
@@ -9573,17 +9576,14 @@ Wrapper.prototype.classes = function classes (className) {
95739576
var classes = classAttribute ? classAttribute.split(' ') : [];
95749577
// Handle converting cssmodules identifiers back to the original class name
95759578
if (this.vm && this.vm.$style) {
9576-
var cssModuleIdentifiers = Object.keys(this.vm.$style).reduce(
9577-
function (acc, key) {
9578-
// $FlowIgnore
9579-
var moduleIdent = this$1.vm.$style[key];
9580-
if (moduleIdent) {
9581-
acc[moduleIdent.split(' ')[0]] = key;
9582-
}
9583-
return acc
9584-
},
9585-
{}
9586-
);
9579+
var cssModuleIdentifiers = keys$1(this.vm.$style).reduce(function (acc, key) {
9580+
// $FlowIgnore
9581+
var moduleIdent = this$1.vm.$style[key];
9582+
if (moduleIdent) {
9583+
acc[moduleIdent.split(' ')[0]] = key;
9584+
}
9585+
return acc
9586+
}, {});
95879587
classes = classes.map(function (name) { return cssModuleIdentifiers[name] || name; });
95889588
}
95899589

@@ -9937,7 +9937,7 @@ Wrapper.prototype.overview = function overview () {
99379937
var computed = this.vm._computedWatchers
99389938
? formatJSON.apply(
99399939
// $FlowIgnore
9940-
void 0, Object.keys(this.vm._computedWatchers).map(function (computedKey) {
9940+
void 0, keys$1(this.vm._computedWatchers).map(function (computedKey) {
99419941
var obj;
99429942

99439943
return (( obj = {}, obj[computedKey] = this$1.vm[computedKey], obj ));
@@ -9961,9 +9961,7 @@ Wrapper.prototype.overview = function overview () {
99619961
var emittedJSONReplacer = function (key, value) { return value instanceof Array
99629962
? value.map(function (calledWith, index) {
99639963
var callParams = calledWith.map(function (param) { return typeof param === 'object'
9964-
? JSON.stringify(param)
9965-
.replace(/"/g, '')
9966-
.replace(/,/g, ', ')
9964+
? JSON.stringify(param).replace(/"/g, '').replace(/,/g, ', ')
99679965
: param; }
99689966
);
99699967

@@ -10145,7 +10143,7 @@ Wrapper.prototype.setMethods = function setMethods (methods) {
1014510143
}
1014610144
this.__warnIfDestroyed();
1014710145

10148-
Object.keys(methods).forEach(function (key) {
10146+
keys$1(methods).forEach(function (key) {
1014910147
// $FlowIgnore : Problem with possibly null this.vm
1015010148
this$1.vm[key] = methods[key];
1015110149
// $FlowIgnore : Problem with possibly null this.vm
@@ -10184,11 +10182,10 @@ Wrapper.prototype.setProps = function setProps (data) {
1018410182

1018510183
this.__warnIfDestroyed();
1018610184

10187-
Object.keys(data).forEach(function (key) {
10185+
keys$1(data).forEach(function (key) {
1018810186
// Don't let people set entire objects, because reactivity won't work
1018910187
if (
10190-
typeof data[key] === 'object' &&
10191-
data[key] !== null &&
10188+
isPlainObject(data[key]) &&
1019210189
// $FlowIgnore : Problem with possibly null this.vm
1019310190
data[key] === this$1.vm[key]
1019410191
) {
@@ -12919,7 +12916,7 @@ function _createLocalVue(
1291912916
var instance = _Vue.extend();
1292012917

1292112918
// clone global APIs
12922-
Object.keys(_Vue).forEach(function (key) {
12919+
keys$1(_Vue).forEach(function (key) {
1292312920
if (!instance.hasOwnProperty(key)) {
1292412921
var original = _Vue[key];
1292512922
// cloneDeep can fail when cloning Vue instances
@@ -12996,7 +12993,7 @@ function compileTemplate(component) {
1299612993
}
1299712994

1299812995
if (component.components) {
12999-
Object.keys(component.components).forEach(function (c) {
12996+
keys$1(component.components).forEach(function (c) {
1300012997
var cmp = component.components[c];
1300112998
if (!cmp.render) {
1300212999
compileTemplate(cmp);
@@ -13014,7 +13011,7 @@ function compileTemplate(component) {
1301413011
}
1301513012

1301613013
function compileTemplateForSlots(slots) {
13017-
Object.keys(slots).forEach(function (key) {
13014+
keys$1(slots).forEach(function (key) {
1301813015
var slot = Array.isArray(slots[key]) ? slots[key] : [slots[key]];
1301913016
slot.forEach(function (slotValue) {
1302013017
if (componentNeedsCompiling(slotValue)) {
@@ -13041,7 +13038,7 @@ function requiresTemplateCompiler(slot) {
1304113038
}
1304213039

1304313040
function validateSlots(slots) {
13044-
Object.keys(slots).forEach(function (key) {
13041+
keys$1(slots).forEach(function (key) {
1304513042
var slot = Array.isArray(slots[key]) ? slots[key] : [slots[key]];
1304613043

1304713044
slot.forEach(function (slotValue) {
@@ -13245,7 +13242,7 @@ function addMocks(
1324513242
if (mockedProperties === false) {
1324613243
return
1324713244
}
13248-
Object.keys(mockedProperties).forEach(function (key) {
13245+
keys$1(mockedProperties).forEach(function (key) {
1324913246
try {
1325013247
// $FlowIgnore
1325113248
_Vue.prototype[key] = mockedProperties[key];
@@ -13280,7 +13277,7 @@ function logEvents(
1328013277

1328113278
function addEventLogger(_Vue) {
1328213279
_Vue.mixin({
13283-
beforeCreate: function() {
13280+
beforeCreate: function () {
1328413281
this.__emitted = Object.create(null);
1328513282
this.__emittedByOrder = [];
1328613283
logEvents(this, this.__emitted, this.__emittedByOrder);
@@ -13328,9 +13325,7 @@ function isDestructuringSlotScope(slotScope) {
1332813325
return /^{.*}$/.test(slotScope)
1332913326
}
1333013327

13331-
function getVueTemplateCompilerHelpers(
13332-
_Vue
13333-
) {
13328+
function getVueTemplateCompilerHelpers(_Vue) {
1333413329
// $FlowIgnore
1333513330
var vue = new _Vue();
1333613331
var helpers = {};
@@ -13429,7 +13424,7 @@ function createScopedSlots(
1342913424

1343013425
var slotScope = scopedSlotMatches.match && scopedSlotMatches.match[1];
1343113426

13432-
scopedSlots[scopedSlotName] = function(props) {
13427+
scopedSlots[scopedSlotName] = function (props) {
1343313428
var obj;
1343413429

1343513430
var res;
@@ -13478,10 +13473,10 @@ function resolveComponent$1(obj, component) {
1347813473
)
1347913474
}
1348013475

13481-
function getCoreProperties(componentOptions) {
13476+
function getCoreProperties(componentOptions, name) {
1348213477
return {
1348313478
attrs: componentOptions.attrs,
13484-
name: componentOptions.name,
13479+
name: componentOptions.name || name,
1348513480
model: componentOptions.model,
1348613481
props: componentOptions.props,
1348713482
on: componentOptions.on,
@@ -13542,7 +13537,7 @@ function createStubFromComponent(
1354213537
Vue__default['default'].config.ignoredElements.push(tagName);
1354313538
}
1354413539

13545-
return Object.assign({}, getCoreProperties(componentOptions),
13540+
return Object.assign({}, getCoreProperties(componentOptions, name),
1354613541
{$_vueTestUtils_original: originalComponent,
1354713542
$_doNotStubChildren: true,
1354813543
render: function render(h, context) {
@@ -13627,7 +13622,7 @@ function createStubsFromStubsObject(
1362713622
) {
1362813623
if ( originalComponents === void 0 ) originalComponents = {};
1362913624

13630-
return Object.keys(stubs || {}).reduce(function (acc, stubName) {
13625+
return keys$1(stubs || {}).reduce(function (acc, stubName) {
1363113626
var stub = stubs[stubName];
1363213627

1363313628
validateStub(stub);
@@ -13723,8 +13718,16 @@ function patchCreateElement(_Vue, stubs, stubAllComponents) {
1372313718
}
1372413719

1372513720
if (isConstructor(el) || isComponentOptions(el)) {
13721+
var componentOptions = isConstructor(el) ? el.options : el;
13722+
var elName = componentOptions.name;
13723+
13724+
var stubbedComponent = resolveComponent(elName, stubs);
13725+
if (stubbedComponent) {
13726+
return originalCreateElement.apply(void 0, [ stubbedComponent ].concat( args ))
13727+
}
13728+
1372613729
if (stubAllComponents) {
13727-
var stub = createStubFromComponent(el, el.name || 'anonymous', _Vue);
13730+
var stub = createStubFromComponent(el, elName || 'anonymous', _Vue);
1372813731
return originalCreateElement.apply(void 0, [ stub ].concat( args ))
1372913732
}
1373013733
var Constructor = shouldExtend(el) ? extend(el, _Vue) : el;
@@ -13837,8 +13840,8 @@ function createInstance(
1383713840

1383813841
// watchers provided in mounting options should override preexisting ones
1383913842
if (componentOptions.watch && instanceOptions.watch) {
13840-
var componentWatchers = Object.keys(componentOptions.watch);
13841-
var instanceWatchers = Object.keys(instanceOptions.watch);
13843+
var componentWatchers = keys$1(componentOptions.watch);
13844+
var instanceWatchers = keys$1(instanceOptions.watch);
1384213845

1384313846
for (var i = 0; i < instanceWatchers.length; i++) {
1384413847
var k = instanceWatchers[i];
@@ -13858,22 +13861,22 @@ function createInstance(
1385813861
var parentComponentOptions = options.parentComponent || {};
1385913862

1386013863
var originalParentComponentProvide = parentComponentOptions.provide;
13861-
parentComponentOptions.provide = function() {
13864+
parentComponentOptions.provide = function () {
1386213865
return Object.assign({}, getValuesFromCallableOption.call(this, originalParentComponentProvide),
1386313866
// $FlowIgnore
1386413867
getValuesFromCallableOption.call(this, options.provide))
1386513868
};
1386613869

1386713870
var originalParentComponentData = parentComponentOptions.data;
13868-
parentComponentOptions.data = function() {
13871+
parentComponentOptions.data = function () {
1386913872
return Object.assign({}, getValuesFromCallableOption.call(this, originalParentComponentData),
1387013873
{vueTestUtils_childProps: Object.assign({}, options.propsData)})
1387113874
};
1387213875

1387313876
parentComponentOptions.$_doNotStubChildren = true;
1387413877
parentComponentOptions.$_isWrapperParent = true;
1387513878
parentComponentOptions._isFunctionalContainer = componentOptions.functional;
13876-
parentComponentOptions.render = function(h) {
13879+
parentComponentOptions.render = function (h) {
1387713880
return h(
1387813881
Constructor,
1387913882
createContext(options, scopedSlots, this.vueTestUtils_childProps),

Diff for: packages/server-test-utils/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@vue/server-test-utils",
3-
"version": "1.3.3",
3+
"version": "1.3.5",
44
"description": "Utilities for testing Vue components.",
55
"main": "dist/vue-server-test-utils.js",
66
"types": "types/index.d.ts",

0 commit comments

Comments
 (0)