Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f6bc715

Browse files
committedSep 28, 2017
docs: tweaks
1 parent 9d988d9 commit f6bc715

40 files changed

+221
-246
lines changed
 

‎dist/vue-test-utils.amd.js

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3468,25 +3468,23 @@ function createInterceptPlugin (interceptedProperties) {
34683468
}
34693469

34703470
function addAttrs (vm, attrs) {
3471-
var consoleWarnSave = console.error;
3472-
console.error = function () {};
3471+
Vue.config.silent = true;
34733472
if (attrs) {
34743473
vm.$attrs = attrs;
34753474
} else {
34763475
vm.$attrs = {};
34773476
}
3478-
console.error = consoleWarnSave;
3477+
Vue.config.silent = false;
34793478
}
34803479

34813480
function addListeners (vm, listeners) {
3482-
var consoleWarnSave = console.error;
3483-
console.error = function () {};
3481+
Vue.config.silent = true;
34843482
if (listeners) {
34853483
vm.$listeners = listeners;
34863484
} else {
34873485
vm.$listeners = {};
34883486
}
3489-
console.error = consoleWarnSave;
3487+
Vue.config.silent = false;
34903488
}
34913489

34923490
function addProvide (component, options) {
@@ -3505,6 +3503,12 @@ function addProvide (component, options) {
35053503

35063504
//
35073505

3506+
function compileTemplate (component) {
3507+
Object.assign(component, vueTemplateCompiler.compileToFunctions(component.template));
3508+
}
3509+
3510+
//
3511+
35083512
function createConstructor (component, options) {
35093513
var vue = options.localVue || Vue;
35103514

@@ -3532,6 +3536,10 @@ function createConstructor (component, options) {
35323536
stubComponents(component, options.stubs);
35333537
}
35343538

3539+
if (!component.render && component.template && !component.functional) {
3540+
compileTemplate(component);
3541+
}
3542+
35353543
var Constructor = vue.extend(component);
35363544

35373545
if (options.intercept) {
@@ -3589,7 +3597,11 @@ function mount (component, options) {
35893597
if ( options === void 0 ) options = {};
35903598

35913599
if (!window) {
3592-
throwError('window is undefined, vue-test-utils needs to be run in a browser environment.\n You can run the tests in node using JSDOM');
3600+
throwError(
3601+
'window is undefined, vue-test-utils needs to be run in a browser environment.\n' +
3602+
'You can run the tests in node using jsdom + jsdom-global.\n' +
3603+
'See https://vue-test-utils.vuejs.org/en/guides/general-tips.html for more details.'
3604+
);
35933605
}
35943606

35953607
var componentToMount = options.clone === false ? component : cloneDeep_1(component);
@@ -3646,6 +3658,11 @@ function createLocalVue () {
36463658
// so that merge strats registered by plguins can work properly
36473659
instance.config.optionMergeStrategies = Vue.config.optionMergeStrategies;
36483660

3661+
// make sure all extends are based on this instance.
3662+
// this is important so that global components registered by plugins,
3663+
// e.g. router-link are created using the correct base constructor
3664+
instance.options._base = instance;
3665+
36493666
// compat for vue-router < 2.7.1 where it does not allow multiple installs
36503667
var use = instance.use;
36513668
instance.use = function (plugin) {

‎dist/vue-test-utils.iife.js

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3469,25 +3469,23 @@ function createInterceptPlugin (interceptedProperties) {
34693469
}
34703470

34713471
function addAttrs (vm, attrs) {
3472-
var consoleWarnSave = console.error;
3473-
console.error = function () {};
3472+
Vue.config.silent = true;
34743473
if (attrs) {
34753474
vm.$attrs = attrs;
34763475
} else {
34773476
vm.$attrs = {};
34783477
}
3479-
console.error = consoleWarnSave;
3478+
Vue.config.silent = false;
34803479
}
34813480

34823481
function addListeners (vm, listeners) {
3483-
var consoleWarnSave = console.error;
3484-
console.error = function () {};
3482+
Vue.config.silent = true;
34853483
if (listeners) {
34863484
vm.$listeners = listeners;
34873485
} else {
34883486
vm.$listeners = {};
34893487
}
3490-
console.error = consoleWarnSave;
3488+
Vue.config.silent = false;
34913489
}
34923490

34933491
function addProvide (component, options) {
@@ -3506,6 +3504,12 @@ function addProvide (component, options) {
35063504

35073505
//
35083506

3507+
function compileTemplate (component) {
3508+
Object.assign(component, vueTemplateCompiler.compileToFunctions(component.template));
3509+
}
3510+
3511+
//
3512+
35093513
function createConstructor (component, options) {
35103514
var vue = options.localVue || Vue;
35113515

@@ -3533,6 +3537,10 @@ function createConstructor (component, options) {
35333537
stubComponents(component, options.stubs);
35343538
}
35353539

3540+
if (!component.render && component.template && !component.functional) {
3541+
compileTemplate(component);
3542+
}
3543+
35363544
var Constructor = vue.extend(component);
35373545

35383546
if (options.intercept) {
@@ -3590,7 +3598,11 @@ function mount (component, options) {
35903598
if ( options === void 0 ) options = {};
35913599

35923600
if (!window) {
3593-
throwError('window is undefined, vue-test-utils needs to be run in a browser environment.\n You can run the tests in node using JSDOM');
3601+
throwError(
3602+
'window is undefined, vue-test-utils needs to be run in a browser environment.\n' +
3603+
'You can run the tests in node using jsdom + jsdom-global.\n' +
3604+
'See https://vue-test-utils.vuejs.org/en/guides/general-tips.html for more details.'
3605+
);
35943606
}
35953607

35963608
var componentToMount = options.clone === false ? component : cloneDeep_1(component);
@@ -3647,6 +3659,11 @@ function createLocalVue () {
36473659
// so that merge strats registered by plguins can work properly
36483660
instance.config.optionMergeStrategies = Vue.config.optionMergeStrategies;
36493661

3662+
// make sure all extends are based on this instance.
3663+
// this is important so that global components registered by plugins,
3664+
// e.g. router-link are created using the correct base constructor
3665+
instance.options._base = instance;
3666+
36503667
// compat for vue-router < 2.7.1 where it does not allow multiple installs
36513668
var use = instance.use;
36523669
instance.use = function (plugin) {

‎dist/vue-test-utils.js

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -939,25 +939,23 @@ function createInterceptPlugin (interceptedProperties) {
939939
}
940940

941941
function addAttrs (vm, attrs) {
942-
var consoleWarnSave = console.error;
943-
console.error = function () {};
942+
Vue.config.silent = true;
944943
if (attrs) {
945944
vm.$attrs = attrs;
946945
} else {
947946
vm.$attrs = {};
948947
}
949-
console.error = consoleWarnSave;
948+
Vue.config.silent = false;
950949
}
951950

952951
function addListeners (vm, listeners) {
953-
var consoleWarnSave = console.error;
954-
console.error = function () {};
952+
Vue.config.silent = true;
955953
if (listeners) {
956954
vm.$listeners = listeners;
957955
} else {
958956
vm.$listeners = {};
959957
}
960-
console.error = consoleWarnSave;
958+
Vue.config.silent = false;
961959
}
962960

963961
function addProvide (component, options) {
@@ -976,6 +974,12 @@ function addProvide (component, options) {
976974

977975
//
978976

977+
function compileTemplate (component) {
978+
Object.assign(component, vueTemplateCompiler.compileToFunctions(component.template));
979+
}
980+
981+
//
982+
979983
function createConstructor (component, options) {
980984
var vue = options.localVue || Vue;
981985

@@ -1003,6 +1007,10 @@ function createConstructor (component, options) {
10031007
stubComponents(component, options.stubs);
10041008
}
10051009

1010+
if (!component.render && component.template && !component.functional) {
1011+
compileTemplate(component);
1012+
}
1013+
10061014
var Constructor = vue.extend(component);
10071015

10081016
if (options.intercept) {
@@ -1060,7 +1068,11 @@ function mount (component, options) {
10601068
if ( options === void 0 ) options = {};
10611069

10621070
if (!window) {
1063-
throwError('window is undefined, vue-test-utils needs to be run in a browser environment.\n You can run the tests in node using JSDOM');
1071+
throwError(
1072+
'window is undefined, vue-test-utils needs to be run in a browser environment.\n' +
1073+
'You can run the tests in node using jsdom + jsdom-global.\n' +
1074+
'See https://vue-test-utils.vuejs.org/en/guides/general-tips.html for more details.'
1075+
);
10641076
}
10651077

10661078
var componentToMount = options.clone === false ? component : cloneDeep(component);
@@ -1117,6 +1129,11 @@ function createLocalVue () {
11171129
// so that merge strats registered by plguins can work properly
11181130
instance.config.optionMergeStrategies = Vue.config.optionMergeStrategies;
11191131

1132+
// make sure all extends are based on this instance.
1133+
// this is important so that global components registered by plugins,
1134+
// e.g. router-link are created using the correct base constructor
1135+
instance.options._base = instance;
1136+
11201137
// compat for vue-router < 2.7.1 where it does not allow multiple installs
11211138
var use = instance.use;
11221139
instance.use = function (plugin) {

‎dist/vue-test-utils.umd.js

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3472,25 +3472,23 @@ function createInterceptPlugin (interceptedProperties) {
34723472
}
34733473

34743474
function addAttrs (vm, attrs) {
3475-
var consoleWarnSave = console.error;
3476-
console.error = function () {};
3475+
Vue.config.silent = true;
34773476
if (attrs) {
34783477
vm.$attrs = attrs;
34793478
} else {
34803479
vm.$attrs = {};
34813480
}
3482-
console.error = consoleWarnSave;
3481+
Vue.config.silent = false;
34833482
}
34843483

34853484
function addListeners (vm, listeners) {
3486-
var consoleWarnSave = console.error;
3487-
console.error = function () {};
3485+
Vue.config.silent = true;
34883486
if (listeners) {
34893487
vm.$listeners = listeners;
34903488
} else {
34913489
vm.$listeners = {};
34923490
}
3493-
console.error = consoleWarnSave;
3491+
Vue.config.silent = false;
34943492
}
34953493

34963494
function addProvide (component, options) {
@@ -3509,6 +3507,12 @@ function addProvide (component, options) {
35093507

35103508
//
35113509

3510+
function compileTemplate (component) {
3511+
Object.assign(component, vueTemplateCompiler.compileToFunctions(component.template));
3512+
}
3513+
3514+
//
3515+
35123516
function createConstructor (component, options) {
35133517
var vue = options.localVue || Vue;
35143518

@@ -3536,6 +3540,10 @@ function createConstructor (component, options) {
35363540
stubComponents(component, options.stubs);
35373541
}
35383542

3543+
if (!component.render && component.template && !component.functional) {
3544+
compileTemplate(component);
3545+
}
3546+
35393547
var Constructor = vue.extend(component);
35403548

35413549
if (options.intercept) {
@@ -3593,7 +3601,11 @@ function mount (component, options) {
35933601
if ( options === void 0 ) options = {};
35943602

35953603
if (!window) {
3596-
throwError('window is undefined, vue-test-utils needs to be run in a browser environment.\n You can run the tests in node using JSDOM');
3604+
throwError(
3605+
'window is undefined, vue-test-utils needs to be run in a browser environment.\n' +
3606+
'You can run the tests in node using jsdom + jsdom-global.\n' +
3607+
'See https://vue-test-utils.vuejs.org/en/guides/general-tips.html for more details.'
3608+
);
35973609
}
35983610

35993611
var componentToMount = options.clone === false ? component : cloneDeep_1(component);
@@ -3650,6 +3662,11 @@ function createLocalVue () {
36503662
// so that merge strats registered by plguins can work properly
36513663
instance.config.optionMergeStrategies = Vue.config.optionMergeStrategies;
36523664

3665+
// make sure all extends are based on this instance.
3666+
// this is important so that global components registered by plugins,
3667+
// e.g. router-link are created using the correct base constructor
3668+
instance.options._base = instance;
3669+
36533670
// compat for vue-router < 2.7.1 where it does not allow multiple installs
36543671
var use = instance.use;
36553672
instance.use = function (plugin) {

‎docs/en/SUMMARY.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,18 @@
88
* [Testing SFCs with Mocha + webpack](guides/testing-SFCs-with-mocha-webpack.md)
99
* [Using with Vuex](guides/using-with-vuex.md)
1010
* [API](api/README.md)
11-
* [createLocalVue](api/createLocalVue.md)
1211
* [mount](api/mount.md)
1312
* [shallow](api/shallow.md)
1413
* [Mounting Options](api/options.md)
14+
- [context](api/options.md#context)
15+
- [slots](api/options.md#slots)
16+
- [stubs](api/options.md#stubs)
17+
- [intercept](api/options.md#intercept)
18+
- [localVue](api/options.md#localvue)
19+
- [attachToDocument](api/options.md#attachtodocument)
20+
- [attrs](api/options.md#attrs)
21+
- [listeners](api/options.md#listeners)
22+
- [clone](api/options.md#clone)
1523
* [Wrapper](api/wrapper/README.md)
1624
* [contains](api/wrapper/contains.md)
1725
* [find](api/wrapper/find.md)
@@ -44,3 +52,4 @@
4452
* [setProps](api/wrapper-array/setProps.md)
4553
* [trigger](api/wrapper-array/trigger.md)
4654
* [Selectors](api/selectors.md)
55+
* [createLocalVue](api/createLocalVue.md)

‎docs/en/api/README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
# API
22

3-
* [createLocalVue](./createLocalVue.md)
43
* [mount](./mount.md)
54
* [shallow](./shallow.md)
6-
* [options](./options.md)
5+
* [Mounting Options](./options.md)
6+
- [context](./options.md#context)
7+
- [slots](./options.md#slots)
8+
- [stubs](./options.md#stubs)
9+
- [intercept](./options.md#intercept)
10+
- [localVue](./options.md#localvue)
11+
- [attachToDocument](./options.md#attachtodocument)
12+
- [attrs](./options.md#attrs)
13+
- [listeners](./options.md#listeners)
14+
- [clone](./options.md#clone)
715
* [Wrapper](./wrapper/README.md)
816
* [contains](./wrapper/contains.md)
917
* [find](./wrapper/find.md)
@@ -35,4 +43,5 @@
3543
* [setData](./wrapper-array/setData.md)
3644
* [setProps](./wrapper-array/setProps.md)
3745
* [trigger](./wrapper-array/trigger.md)
46+
* [createLocalVue](./createLocalVue.md)
3847
* [Selectors](./selectors.md)

0 commit comments

Comments
 (0)
Please sign in to comment.