From d98e279de9ce2fe8441b44c09d9094f58f74431f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 12 Apr 2022 22:08:12 +0000 Subject: [PATCH 01/18] chore(deps-dev): bump vue-tsc from 0.34.5 to 0.34.6 Bumps [vue-tsc](https://github.com/johnsoncodehk/volar/tree/HEAD/packages/vue-tsc) from 0.34.5 to 0.34.6. - [Release notes](https://github.com/johnsoncodehk/volar/releases) - [Changelog](https://github.com/johnsoncodehk/volar/blob/master/CHANGELOG.md) - [Commits](https://github.com/johnsoncodehk/volar/commits/v0.34.6/packages/vue-tsc) --- updated-dependencies: - dependency-name: vue-tsc dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- package.json | 2 +- yarn.lock | 54 ++++++++++++++++++++++++++-------------------------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/package.json b/package.json index c802ad3e9..d41c46c80 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "vue-class-component": "^8.0.0-rc.1", "vue-jest": "^5.0.0-alpha.10", "vue-router": "^4.0.14", - "vue-tsc": "0.34.5", + "vue-tsc": "0.34.6", "vuex": "^4.0.2" }, "peerDependencies": { diff --git a/yarn.lock b/yarn.lock index aa9a6c9ae..937662399 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1682,37 +1682,37 @@ resolved "https://registry.yarnpkg.com/@vitejs/plugin-vue/-/plugin-vue-2.2.0.tgz#a0affe3ee09f70a9a1415bd39c0f8a58fa78b419" integrity sha512-wXigM1EwN2G7rZcwG6kLk9ivvIMhx2363tCEvMBiXcTu5nePM/12hUPVzPb83Uugt6U+zom1gTpJopi/Ow/jwg== -"@volar/code-gen@0.34.5": - version "0.34.5" - resolved "https://registry.yarnpkg.com/@volar/code-gen/-/code-gen-0.34.5.tgz#dc5feafcf759fb3166631583dc6a0d9e7cd30d33" - integrity sha512-uiR7YuIx3l13ZhZH9I4plsmuFUhAJQNnJ+HEgYB9Wf/YjdLC5KMKL4ImOIUodFo9d+rYl2FwRACGCsaXT9th8Q== +"@volar/code-gen@0.34.6": + version "0.34.6" + resolved "https://registry.yarnpkg.com/@volar/code-gen/-/code-gen-0.34.6.tgz#1622a8fd0f82044b6d6fcf903d1c4ad979e72e14" + integrity sha512-sFgiaN3F+Sy93uVDtnZxfhEdy15ERSZ9qHY9wny4oQHztxS0pscrIGOQcvSoaK3pcyR8xGTouXkNf0BsOUwuXA== dependencies: - "@volar/source-map" "0.34.5" + "@volar/source-map" "0.34.6" -"@volar/source-map@0.34.5": - version "0.34.5" - resolved "https://registry.yarnpkg.com/@volar/source-map/-/source-map-0.34.5.tgz#4fd98c7f30a189bb1f0e2797ff76f575ca9dfc57" - integrity sha512-l/6LAl0JEI4jqVQdLkNHen8b6jb10tuk96VUAZaiwvD0WxHJ3rkhMA7igThSNIfekDLx/kTPUQJX6nhbYs6xgQ== +"@volar/source-map@0.34.6": + version "0.34.6" + resolved "https://registry.yarnpkg.com/@volar/source-map/-/source-map-0.34.6.tgz#b1e6a235460e48723af2b3cd8a56e7f28fe39623" + integrity sha512-TIAxtvFIANh0PfQFY7dT/f2MIvpNRzJ7xrvlqwl1oYt7sa8AIposBFGS873s4avOuz15AoubKU7uZnVLYJ5AWg== -"@volar/vue-code-gen@0.34.5": - version "0.34.5" - resolved "https://registry.yarnpkg.com/@volar/vue-code-gen/-/vue-code-gen-0.34.5.tgz#f02fc83c5f2e72442169b83bad291664c5b7307a" - integrity sha512-rSbrEiJV7SaACdyXAQUIf1urHY/AM31Ywq1secG4y5hWRc0k2iH0cLKcmHnHKAcfPO0F5BcEHmiNDfMjOe9c+A== +"@volar/vue-code-gen@0.34.6": + version "0.34.6" + resolved "https://registry.yarnpkg.com/@volar/vue-code-gen/-/vue-code-gen-0.34.6.tgz#6931ae1197bdcf66fef92238453bffaeb8fdf266" + integrity sha512-0wh5fhQsxY6GL/zrxabjY+lAsFsaUNWDl+45iVeuczGP9sU07lpHoCwHBHBqCK8kxbvAJZaa3Me66apoq5BEvw== dependencies: - "@volar/code-gen" "0.34.5" - "@volar/source-map" "0.34.5" + "@volar/code-gen" "0.34.6" + "@volar/source-map" "0.34.6" "@vue/compiler-core" "^3.2.31" "@vue/compiler-dom" "^3.2.31" "@vue/shared" "^3.2.31" -"@volar/vue-typescript@0.34.5": - version "0.34.5" - resolved "https://registry.yarnpkg.com/@volar/vue-typescript/-/vue-typescript-0.34.5.tgz#19af17e2c7dac13da3bbe47b95906d6c6a5d170f" - integrity sha512-Q6j4rfghk9DYaBjvyC9kNUNK3v0TfuTjMgmn73hd6uZ7xHQj2uMSqoTRhIjoyk0QhyOkDh10/SMafcr2ooBa/w== +"@volar/vue-typescript@0.34.6": + version "0.34.6" + resolved "https://registry.yarnpkg.com/@volar/vue-typescript/-/vue-typescript-0.34.6.tgz#a7b78550d1ee6226018fbdbb7afa6ae27ceb1288" + integrity sha512-vKEYnDw9BhIMR6+Rp1Ue/8TpBjYNm4+3fIom4wMxFDlEOCku7fsF169QgZuDDvyPrFlurT878qjKYf88cYFCgA== dependencies: - "@volar/code-gen" "0.34.5" - "@volar/source-map" "0.34.5" - "@volar/vue-code-gen" "0.34.5" + "@volar/code-gen" "0.34.6" + "@volar/source-map" "0.34.6" + "@volar/vue-code-gen" "0.34.6" "@vue/compiler-sfc" "^3.2.31" "@vue/reactivity" "^3.2.31" @@ -5325,12 +5325,12 @@ vue-router@^4.0.14: dependencies: "@vue/devtools-api" "^6.0.0" -vue-tsc@0.34.5: - version "0.34.5" - resolved "https://registry.yarnpkg.com/vue-tsc/-/vue-tsc-0.34.5.tgz#048709dfbf0382ada092d745a06acacca35b571a" - integrity sha512-3wEZvztZc74VJ39e8xWhimgTw2U5bi73PAUhdoe58azX8dsUM0YMUJbSdcqZZX7U0V+5wco1x5IcjrK7MvcbJA== +vue-tsc@0.34.6: + version "0.34.6" + resolved "https://registry.yarnpkg.com/vue-tsc/-/vue-tsc-0.34.6.tgz#cabb5dd60d8e0c998717472cd8806d93741914df" + integrity sha512-rEr8/BrpSN2QmnTw6MuT0WJA/qx54xDqSXG6EBGt37fn7jLCrKYF37GW3xZCdktO0V53l1XF2ssBtmLL+OI2ww== dependencies: - "@volar/vue-typescript" "0.34.5" + "@volar/vue-typescript" "0.34.6" vue@3.2.32: version "3.2.32" From 21b8b4f52a6c64f77957fe674ddcb206d2ecfda1 Mon Sep 17 00:00:00 2001 From: freakzlike Date: Sat, 16 Apr 2022 11:28:31 +0200 Subject: [PATCH 02/18] docs: add testing composables section (#1412) * docs: Add testing composables section * docs: Add provide/inject section * docs: Add mock of API request to testing composables section --- .../guide/advanced/reusability-composition.md | 213 +++++++++++++++++- 1 file changed, 212 insertions(+), 1 deletion(-) diff --git a/docs/guide/advanced/reusability-composition.md b/docs/guide/advanced/reusability-composition.md index 46be49e28..c51a65546 100644 --- a/docs/guide/advanced/reusability-composition.md +++ b/docs/guide/advanced/reusability-composition.md @@ -2,6 +2,217 @@ Mostly: -- `global.provide`. - `global.mixins`. - `global.directives`. + +## Testing composables + +When working with the composition API and creating composables, you often want to test only the composable. Let's start +with a simple example: + +```typescript +export function useCounter() { + const counter = ref(0) + + function increase() { + counter.value += 1 + } + + return { counter, increase } +} +``` + +In this case, you don't actually need `@vue/test-utils`. Here is the corresponding test: + +```typescript +test('increase counter on call', () => { + const { counter, increase } = useCounter() + + expect(counter.value).toBe(0) + + increase() + + expect(counter.value).toBe(1) +}) +``` + +For more complex composables, which use lifecycle hooks like `onMounted` or `provide`/`inject` handling, you can create +a simple test helper component. The following composable fetches the user data within the `onMounted` hook. + +```typescript +export function useUser(userId) { + const user = ref() + + function fetchUser(id) { + axios.get(`users/${id}`) + .then(response => (user.value = response.data)) + } + + onMounted(() => fetchUser(userId)) + + return { user } +} +``` + +To test this composable, you can create a simple `TestComponent` within the tests. The `TestComponent` should use the +composable the exact same way how the real components would use it. + +```typescript +// Mock API request +jest.spyOn(axios, 'get').mockResolvedValue({ data: { id: 1, name: 'User' } }) + +test('fetch user on mount', async () => { + const TestComponent = defineComponent({ + props: { + // Define props, to test the composable with different input arguments + userId: { + type: Number, + required: true + } + }, + setup (props) { + return { + // Call the composable and expose all return values into our + // component instance so we can access them with wrapper.vm + ...useUser(props.userId) + } + } + }) + + const wrapper = mount(TestComponent, { + props: { + userId: 1 + } + }) + + expect(wrapper.vm.user).toBeUndefined() + + await flushPromises() + + expect(wrapper.vm.user).toEqual({ id: 1, name: 'User' }) +}) +``` + +## Provide / inject + +Vue offers a way to pass props to all child components with `provide` and `inject`. The best way to test this behavior +is to test the entire tree (parent + children). But sometimes this is not possible, because the tree is too complex, or +you only want to test a single composable. + +### Testing `provide` + +Let's assume the following component you want to test: +```vue + + + +``` + +In this case you could either render an actual child component and test the correct usage of `provide` or you can create +a simple test helper component and pass it into the default slot. + +```typescript +test('provides correct data', () => { + const TestComponent = defineComponent({ + template: '{{value}}', + setup () { + const value = inject('my-key') + return { value } + } + }) + + const wrapper = mount(ParentComponent, { + slots: { + default: () => h(TestComponent) + } + }) + + expect(wrapper.find('#provide-test').text()).toBe('some-data') +}) +``` + +If your component does not contain a slot you can use a [`stub`](./stubs-shallow-mount.md#stubbing-a-single-child-component) +and replace a child component with your test helper: + +```vue + + + +``` + +And the test: + +```typescript +test('provides correct data', () => { + const TestComponent = defineComponent({ + template: '{{value}}', + setup () { + const value = inject('my-key') + return { value } + } + }) + + const wrapper = mount(ParentComponent, { + global: { + stubs: { + SomeChild: TestComponent + } + } + }) + + expect(wrapper.find('#provide-test').text()).toBe('some-data') +}) +``` + +### Testing `inject` + +When your Component uses `inject` and you need to pass data with `provide`, then you can use the `global.provides` option. + +```vue + + + +``` + +The unit test could simply look like: + +```typescript +test('renders correct data', () => { + const wrapper = mount(MyComponent, { + global: { + provides: { + 'my-key': 'some-data' + } + } + }) + + expect(wrapper.text()).toBe('some-data') +}) +``` + +## Conclusion + +- test simple composables without a component and `@vue/test-utils` +- create a test helper component to test more complex composables +- create a test helper component to test your component provides the correct data with `provide` +- use `global.provides` to pass data to your component which uses `inject` From 50584fe31829a14a338246b8457fd3f357df7924 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Apr 2022 10:29:47 +1000 Subject: [PATCH 03/18] chore(deps-dev): bump rollup from 2.70.1 to 2.70.2 (#1432) Bumps [rollup](https://github.com/rollup/rollup) from 2.70.1 to 2.70.2. - [Release notes](https://github.com/rollup/rollup/releases) - [Changelog](https://github.com/rollup/rollup/blob/master/CHANGELOG.md) - [Commits](https://github.com/rollup/rollup/compare/v2.70.1...v2.70.2) --- updated-dependencies: - dependency-name: rollup dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index d41c46c80..430dcb407 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "prettier": "^2.6.2", "pretty": "^2.0.0", "reflect-metadata": "^0.1.13", - "rollup": "^2.70.1", + "rollup": "^2.70.2", "rollup-plugin-typescript2": "^0.31.2", "ts-jest": "27.1.4", "tslib": "2.3.1", diff --git a/yarn.lock b/yarn.lock index 937662399..058229eee 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4734,10 +4734,10 @@ rollup-plugin-typescript2@^0.31.2: resolve "^1.20.0" tslib "^2.3.1" -rollup@^2.59.0, rollup@^2.70.1: - version "2.70.1" - resolved "https://registry.yarnpkg.com/rollup/-/rollup-2.70.1.tgz#824b1f1f879ea396db30b0fc3ae8d2fead93523e" - integrity sha512-CRYsI5EuzLbXdxC6RnYhOuRdtz4bhejPMSWjsFLfVM/7w/85n2szZv6yExqUXsBdz5KT8eoubeyDUDjhLHEslA== +rollup@^2.59.0, rollup@^2.70.2: + version "2.70.2" + resolved "https://registry.yarnpkg.com/rollup/-/rollup-2.70.2.tgz#808d206a8851628a065097b7ba2053bd83ba0c0d" + integrity sha512-EitogNZnfku65I1DD5Mxe8JYRUCy0hkK5X84IlDtUs+O6JRMpRciXTzyCUuX11b5L5pvjH+OmFXiQ3XjabcXgg== optionalDependencies: fsevents "~2.3.2" From 5ad1a03e86cf6de68e4f0191b981a134649f29db Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Apr 2022 10:30:01 +1000 Subject: [PATCH 04/18] chore(deps-dev): bump @rollup/plugin-node-resolve from 13.1.3 to 13.2.1 (#1431) Bumps [@rollup/plugin-node-resolve](https://github.com/rollup/plugins/tree/HEAD/packages/node-resolve) from 13.1.3 to 13.2.1. - [Release notes](https://github.com/rollup/plugins/releases) - [Changelog](https://github.com/rollup/plugins/blob/master/packages/node-resolve/CHANGELOG.md) - [Commits](https://github.com/rollup/plugins/commits/node-resolve-v13.2.1/packages/node-resolve) --- updated-dependencies: - dependency-name: "@rollup/plugin-node-resolve" dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 430dcb407..72eecfa43 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "@babel/types": "^7.17.0", "@rollup/plugin-commonjs": "^21.0.3", "@rollup/plugin-json": "^4.1.0", - "@rollup/plugin-node-resolve": "^13.1.3", + "@rollup/plugin-node-resolve": "^13.2.1", "@rollup/plugin-replace": "^4.0.0", "@types/jest": "27.4.1", "@types/node": "17.0.23", diff --git a/yarn.lock b/yarn.lock index 058229eee..0ecc7a562 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1392,10 +1392,10 @@ dependencies: "@rollup/pluginutils" "^3.0.8" -"@rollup/plugin-node-resolve@^13.1.3": - version "13.1.3" - resolved "https://registry.yarnpkg.com/@rollup/plugin-node-resolve/-/plugin-node-resolve-13.1.3.tgz#2ed277fb3ad98745424c1d2ba152484508a92d79" - integrity sha512-BdxNk+LtmElRo5d06MGY4zoepyrXX1tkzX2hrnPEZ53k78GuOMWLqmJDGIIOPwVRIFZrLQOo+Yr6KtCuLIA0AQ== +"@rollup/plugin-node-resolve@^13.2.1": + version "13.2.1" + resolved "https://registry.yarnpkg.com/@rollup/plugin-node-resolve/-/plugin-node-resolve-13.2.1.tgz#cdee815cf02c180ff0a42536ca67a8f67e299f84" + integrity sha512-btX7kzGvp1JwShQI9V6IM841YKNPYjKCvUbNrQ2EcVYbULtUd/GH6wZ/qdqH13j9pOHBER+EZXNN2L8RSJhVRA== dependencies: "@rollup/pluginutils" "^3.1.0" "@types/resolve" "1.17.1" From 70beac58699891950fd70c09b11c4395d5dffc96 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Apr 2022 10:46:32 +1000 Subject: [PATCH 05/18] chore(deps-dev): bump @rollup/plugin-commonjs from 21.0.3 to 21.1.0 (#1430) Bumps [@rollup/plugin-commonjs](https://github.com/rollup/plugins/tree/HEAD/packages/commonjs) from 21.0.3 to 21.1.0. - [Release notes](https://github.com/rollup/plugins/releases) - [Changelog](https://github.com/rollup/plugins/blob/master/packages/commonjs/CHANGELOG.md) - [Commits](https://github.com/rollup/plugins/commits/commonjs-v21.1.0/packages/commonjs) --- updated-dependencies: - dependency-name: "@rollup/plugin-commonjs" dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 72eecfa43..9056ac23d 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "@babel/core": "^7.17.9", "@babel/preset-env": "^7.16.11", "@babel/types": "^7.17.0", - "@rollup/plugin-commonjs": "^21.0.3", + "@rollup/plugin-commonjs": "^21.1.0", "@rollup/plugin-json": "^4.1.0", "@rollup/plugin-node-resolve": "^13.2.1", "@rollup/plugin-replace": "^4.0.0", diff --git a/yarn.lock b/yarn.lock index 0ecc7a562..59ed5a84d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1372,10 +1372,10 @@ "@nodelib/fs.scandir" "2.1.5" fastq "^1.6.0" -"@rollup/plugin-commonjs@^21.0.3": - version "21.0.3" - resolved "https://registry.yarnpkg.com/@rollup/plugin-commonjs/-/plugin-commonjs-21.0.3.tgz#287896c64926ef3d7f0013708dcdcc1223576ef0" - integrity sha512-ThGfwyvcLc6cfP/MWxA5ACF+LZCvsuhUq7V5134Az1oQWsiC7lNpLT4mJI86WQunK7BYmpUiHmMk2Op6OAHs0g== +"@rollup/plugin-commonjs@^21.1.0": + version "21.1.0" + resolved "https://registry.yarnpkg.com/@rollup/plugin-commonjs/-/plugin-commonjs-21.1.0.tgz#45576d7b47609af2db87f55a6d4b46e44fc3a553" + integrity sha512-6ZtHx3VHIp2ReNNDxHjuUml6ur+WcQ28N1yHgCQwsbNkQg2suhxGMDQGJOn/KuDxKtd1xuZP5xSTwBA4GQ8hbA== dependencies: "@rollup/pluginutils" "^3.1.0" commondir "^1.0.1" From 3ebc6107f8c88c575d8702cae58f5057b14ecb8b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 19 Apr 2022 11:55:01 +1000 Subject: [PATCH 06/18] chore(deps-dev): bump @typescript-eslint/parser from 5.19.0 to 5.20.0 (#1437) Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 5.19.0 to 5.20.0. - [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases) - [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/CHANGELOG.md) - [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v5.20.0/packages/parser) --- updated-dependencies: - dependency-name: "@typescript-eslint/parser" dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- yarn.lock | 50 ++++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 43 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 9056ac23d..d5e02d140 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "@types/node": "17.0.23", "@types/pretty": "^2.0.1", "@typescript-eslint/eslint-plugin": "^5.19.0", - "@typescript-eslint/parser": "^5.19.0", + "@typescript-eslint/parser": "^5.20.0", "@vue/babel-plugin-jsx": "^1.1.1", "@vue/compat": "3.2.32", "@vue/compiler-dom": "3.2.32", diff --git a/yarn.lock b/yarn.lock index 59ed5a84d..4f33d57f0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1612,14 +1612,14 @@ semver "^7.3.5" tsutils "^3.21.0" -"@typescript-eslint/parser@^5.19.0": - version "5.19.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-5.19.0.tgz#05e587c1492868929b931afa0cb5579b0f728e75" - integrity sha512-yhktJjMCJX8BSBczh1F/uY8wGRYrBeyn84kH6oyqdIJwTGKmzX5Qiq49LRQ0Jh0LXnWijEziSo6BRqny8nqLVQ== - dependencies: - "@typescript-eslint/scope-manager" "5.19.0" - "@typescript-eslint/types" "5.19.0" - "@typescript-eslint/typescript-estree" "5.19.0" +"@typescript-eslint/parser@^5.20.0": + version "5.20.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-5.20.0.tgz#4991c4ee0344315c2afc2a62f156565f689c8d0b" + integrity sha512-UWKibrCZQCYvobmu3/N8TWbEeo/EPQbS41Ux1F9XqPzGuV7pfg6n50ZrFo6hryynD8qOTTfLHtHjjdQtxJ0h/w== + dependencies: + "@typescript-eslint/scope-manager" "5.20.0" + "@typescript-eslint/types" "5.20.0" + "@typescript-eslint/typescript-estree" "5.20.0" debug "^4.3.2" "@typescript-eslint/scope-manager@5.19.0": @@ -1630,6 +1630,14 @@ "@typescript-eslint/types" "5.19.0" "@typescript-eslint/visitor-keys" "5.19.0" +"@typescript-eslint/scope-manager@5.20.0": + version "5.20.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.20.0.tgz#79c7fb8598d2942e45b3c881ced95319818c7980" + integrity sha512-h9KtuPZ4D/JuX7rpp1iKg3zOH0WNEa+ZIXwpW/KWmEFDxlA/HSfCMhiyF1HS/drTICjIbpA6OqkAhrP/zkCStg== + dependencies: + "@typescript-eslint/types" "5.20.0" + "@typescript-eslint/visitor-keys" "5.20.0" + "@typescript-eslint/type-utils@5.19.0": version "5.19.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-5.19.0.tgz#80f2125b0dfe82494bbae1ea99f1c0186d420282" @@ -1644,6 +1652,11 @@ resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.19.0.tgz#12d3d600d754259da771806ee8b2c842d3be8d12" integrity sha512-zR1ithF4Iyq1wLwkDcT+qFnhs8L5VUtjgac212ftiOP/ZZUOCuuF2DeGiZZGQXGoHA50OreZqLH5NjDcDqn34w== +"@typescript-eslint/types@5.20.0": + version "5.20.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.20.0.tgz#fa39c3c2aa786568302318f1cb51fcf64258c20c" + integrity sha512-+d8wprF9GyvPwtoB4CxBAR/s0rpP25XKgnOvMf/gMXYDvlUC3rPFHupdTQ/ow9vn7UDe5rX02ovGYQbv/IUCbg== + "@typescript-eslint/typescript-estree@5.19.0": version "5.19.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.19.0.tgz#fc987b8f62883f9ea6a5b488bdbcd20d33c0025f" @@ -1657,6 +1670,19 @@ semver "^7.3.5" tsutils "^3.21.0" +"@typescript-eslint/typescript-estree@5.20.0": + version "5.20.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.20.0.tgz#ab73686ab18c8781bbf249c9459a55dc9417d6b0" + integrity sha512-36xLjP/+bXusLMrT9fMMYy1KJAGgHhlER2TqpUVDYUQg4w0q/NW/sg4UGAgVwAqb8V4zYg43KMUpM8vV2lve6w== + dependencies: + "@typescript-eslint/types" "5.20.0" + "@typescript-eslint/visitor-keys" "5.20.0" + debug "^4.3.2" + globby "^11.0.4" + is-glob "^4.0.3" + semver "^7.3.5" + tsutils "^3.21.0" + "@typescript-eslint/utils@5.19.0": version "5.19.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.19.0.tgz#fe87f1e3003d9973ec361ed10d36b4342f1ded1e" @@ -1677,6 +1703,14 @@ "@typescript-eslint/types" "5.19.0" eslint-visitor-keys "^3.0.0" +"@typescript-eslint/visitor-keys@5.20.0": + version "5.20.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.20.0.tgz#70236b5c6b67fbaf8b2f58bf3414b76c1e826c2a" + integrity sha512-1flRpNF+0CAQkMNlTJ6L/Z5jiODG/e5+7mk6XwtPOUS3UrTz3UOiAg9jG2VtKsWI6rZQfy4C6a232QNRZTRGlg== + dependencies: + "@typescript-eslint/types" "5.20.0" + eslint-visitor-keys "^3.0.0" + "@vitejs/plugin-vue@^2.2.0": version "2.2.0" resolved "https://registry.yarnpkg.com/@vitejs/plugin-vue/-/plugin-vue-2.2.0.tgz#a0affe3ee09f70a9a1415bd39c0f8a58fa78b419" From d4aeee0b37d21596b72454b3b75a5ea9ef03308a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 19 Apr 2022 11:55:08 +1000 Subject: [PATCH 07/18] chore(deps-dev): bump lint-staged from 12.3.7 to 12.3.8 (#1429) Bumps [lint-staged](https://github.com/okonet/lint-staged) from 12.3.7 to 12.3.8. - [Release notes](https://github.com/okonet/lint-staged/releases) - [Commits](https://github.com/okonet/lint-staged/compare/v12.3.7...v12.3.8) --- updated-dependencies: - dependency-name: lint-staged dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index d5e02d140..993727bb4 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "jest": "27.5.1", "jsdom": "^19.0.0", "jsdom-global": "^3.0.2", - "lint-staged": "^12.3.7", + "lint-staged": "^12.3.8", "prettier": "^2.6.2", "pretty": "^2.0.0", "reflect-metadata": "^0.1.13", diff --git a/yarn.lock b/yarn.lock index 4f33d57f0..b03b6d5eb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4125,10 +4125,10 @@ lines-and-columns@^1.1.6: resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.2.4.tgz#eca284f75d2965079309dc0ad9255abb2ebc1632" integrity sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg== -lint-staged@^12.3.7: - version "12.3.7" - resolved "https://registry.yarnpkg.com/lint-staged/-/lint-staged-12.3.7.tgz#ad0e2014302f704f9cf2c0ebdb97ac63d0f17be0" - integrity sha512-/S4D726e2GIsDVWIk1XGvheCaDm1SJRQp8efamZFWJxQMVEbOwSysp7xb49Oo73KYCdy97mIWinhlxcoNqIfIQ== +lint-staged@^12.3.8: + version "12.3.8" + resolved "https://registry.yarnpkg.com/lint-staged/-/lint-staged-12.3.8.tgz#ee3fe2e16c9d76f99d8348072900b017d6d76901" + integrity sha512-0+UpNaqIwKRSGAFOCcpuYNIv/j5QGVC+xUVvmSdxHO+IfIGoHbFLo3XcPmV/LLnsVj5EAncNHVtlITSoY5qWGQ== dependencies: cli-truncate "^3.1.0" colorette "^2.0.16" From 53daf1f97ecc98f0fbd26823ec3ad491c5b1a864 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 19 Apr 2022 11:55:13 +1000 Subject: [PATCH 08/18] chore(deps-dev): bump @types/node from 17.0.23 to 17.0.25 (#1440) Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 17.0.23 to 17.0.25. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node) --- updated-dependencies: - dependency-name: "@types/node" dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 993727bb4..90956169c 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "@rollup/plugin-node-resolve": "^13.2.1", "@rollup/plugin-replace": "^4.0.0", "@types/jest": "27.4.1", - "@types/node": "17.0.23", + "@types/node": "17.0.25", "@types/pretty": "^2.0.1", "@typescript-eslint/eslint-plugin": "^5.19.0", "@typescript-eslint/parser": "^5.20.0", diff --git a/yarn.lock b/yarn.lock index b03b6d5eb..16899de2f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1543,10 +1543,10 @@ resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.11.tgz#d421b6c527a3037f7c84433fd2c4229e016863d3" integrity sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ== -"@types/node@*", "@types/node@17.0.23": - version "17.0.23" - resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.23.tgz#3b41a6e643589ac6442bdbd7a4a3ded62f33f7da" - integrity sha512-UxDxWn7dl97rKVeVS61vErvw086aCYhDLyvRQZ5Rk65rZKepaFdm53GeqXaKBuOhED4e9uWq34IC3TdSdJJ2Gw== +"@types/node@*", "@types/node@17.0.25": + version "17.0.25" + resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.25.tgz#527051f3c2f77aa52e5dc74e45a3da5fb2301448" + integrity sha512-wANk6fBrUwdpY4isjWrKTufkrXdu1D2YHCot2fD/DfWxF5sMrVSA+KN7ydckvaTCh0HiqX9IVl0L5/ZoXg5M7w== "@types/prettier@^2.1.5": version "2.3.2" From 3ce24430ee7385250d64a53e07435c7aee5e8d85 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 19 Apr 2022 11:55:18 +1000 Subject: [PATCH 09/18] chore(deps-dev): bump vue-tsc from 0.34.6 to 0.34.7 (#1439) Bumps [vue-tsc](https://github.com/johnsoncodehk/volar/tree/HEAD/packages/vue-tsc) from 0.34.6 to 0.34.7. - [Release notes](https://github.com/johnsoncodehk/volar/releases) - [Changelog](https://github.com/johnsoncodehk/volar/blob/master/CHANGELOG.md) - [Commits](https://github.com/johnsoncodehk/volar/commits/v0.34.7/packages/vue-tsc) --- updated-dependencies: - dependency-name: vue-tsc dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- yarn.lock | 54 ++++++++++++++++++++++++++-------------------------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/package.json b/package.json index 90956169c..48965ef5b 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "vue-class-component": "^8.0.0-rc.1", "vue-jest": "^5.0.0-alpha.10", "vue-router": "^4.0.14", - "vue-tsc": "0.34.6", + "vue-tsc": "0.34.7", "vuex": "^4.0.2" }, "peerDependencies": { diff --git a/yarn.lock b/yarn.lock index 16899de2f..781224e99 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1716,37 +1716,37 @@ resolved "https://registry.yarnpkg.com/@vitejs/plugin-vue/-/plugin-vue-2.2.0.tgz#a0affe3ee09f70a9a1415bd39c0f8a58fa78b419" integrity sha512-wXigM1EwN2G7rZcwG6kLk9ivvIMhx2363tCEvMBiXcTu5nePM/12hUPVzPb83Uugt6U+zom1gTpJopi/Ow/jwg== -"@volar/code-gen@0.34.6": - version "0.34.6" - resolved "https://registry.yarnpkg.com/@volar/code-gen/-/code-gen-0.34.6.tgz#1622a8fd0f82044b6d6fcf903d1c4ad979e72e14" - integrity sha512-sFgiaN3F+Sy93uVDtnZxfhEdy15ERSZ9qHY9wny4oQHztxS0pscrIGOQcvSoaK3pcyR8xGTouXkNf0BsOUwuXA== +"@volar/code-gen@0.34.7": + version "0.34.7" + resolved "https://registry.yarnpkg.com/@volar/code-gen/-/code-gen-0.34.7.tgz#be04a8b20ccfd31da8c23fcb7e25cd1932e2f16d" + integrity sha512-E1N1VGlChXd0D7WPmmjKhtcZdUKNpBFC4BRqfY+7FZGh89FZlw3uG6Nn76/DjMBLVhfCIY9vA8pwWIN1lI8nYw== dependencies: - "@volar/source-map" "0.34.6" + "@volar/source-map" "0.34.7" -"@volar/source-map@0.34.6": - version "0.34.6" - resolved "https://registry.yarnpkg.com/@volar/source-map/-/source-map-0.34.6.tgz#b1e6a235460e48723af2b3cd8a56e7f28fe39623" - integrity sha512-TIAxtvFIANh0PfQFY7dT/f2MIvpNRzJ7xrvlqwl1oYt7sa8AIposBFGS873s4avOuz15AoubKU7uZnVLYJ5AWg== +"@volar/source-map@0.34.7": + version "0.34.7" + resolved "https://registry.yarnpkg.com/@volar/source-map/-/source-map-0.34.7.tgz#e154d5e3411fb8bfdbc1760af2b4d99b5c91eb18" + integrity sha512-KBNcKCWKsY2f965xuuT4dSbt8GR6nHMzb9gi7ucUHtmRQnvrB31BLBvZNQTHMqkbhRmKArDSuIrbUUG9yu0OXQ== -"@volar/vue-code-gen@0.34.6": - version "0.34.6" - resolved "https://registry.yarnpkg.com/@volar/vue-code-gen/-/vue-code-gen-0.34.6.tgz#6931ae1197bdcf66fef92238453bffaeb8fdf266" - integrity sha512-0wh5fhQsxY6GL/zrxabjY+lAsFsaUNWDl+45iVeuczGP9sU07lpHoCwHBHBqCK8kxbvAJZaa3Me66apoq5BEvw== +"@volar/vue-code-gen@0.34.7": + version "0.34.7" + resolved "https://registry.yarnpkg.com/@volar/vue-code-gen/-/vue-code-gen-0.34.7.tgz#651d879c7be0885d35181951850a1c60aaa8290e" + integrity sha512-vejzO30QrDAEZKguZI8hlAnKhwNoX1INXrOMurlmwCbNft2oEloT+ikFF8QYDz3vWWrdFSsoOKp3BTHyurJ5Nw== dependencies: - "@volar/code-gen" "0.34.6" - "@volar/source-map" "0.34.6" + "@volar/code-gen" "0.34.7" + "@volar/source-map" "0.34.7" "@vue/compiler-core" "^3.2.31" "@vue/compiler-dom" "^3.2.31" "@vue/shared" "^3.2.31" -"@volar/vue-typescript@0.34.6": - version "0.34.6" - resolved "https://registry.yarnpkg.com/@volar/vue-typescript/-/vue-typescript-0.34.6.tgz#a7b78550d1ee6226018fbdbb7afa6ae27ceb1288" - integrity sha512-vKEYnDw9BhIMR6+Rp1Ue/8TpBjYNm4+3fIom4wMxFDlEOCku7fsF169QgZuDDvyPrFlurT878qjKYf88cYFCgA== +"@volar/vue-typescript@0.34.7": + version "0.34.7" + resolved "https://registry.yarnpkg.com/@volar/vue-typescript/-/vue-typescript-0.34.7.tgz#82a684e098dd86337462aa118a2d0e50e93e09d0" + integrity sha512-Ebln64LQutjuNs8nk57oFo45JMQVdZKThkNAeFrzaqB0UItazRQpSXet4vHzfV18FMCV3Cc6fEqZ14WZzQAxgQ== dependencies: - "@volar/code-gen" "0.34.6" - "@volar/source-map" "0.34.6" - "@volar/vue-code-gen" "0.34.6" + "@volar/code-gen" "0.34.7" + "@volar/source-map" "0.34.7" + "@volar/vue-code-gen" "0.34.7" "@vue/compiler-sfc" "^3.2.31" "@vue/reactivity" "^3.2.31" @@ -5359,12 +5359,12 @@ vue-router@^4.0.14: dependencies: "@vue/devtools-api" "^6.0.0" -vue-tsc@0.34.6: - version "0.34.6" - resolved "https://registry.yarnpkg.com/vue-tsc/-/vue-tsc-0.34.6.tgz#cabb5dd60d8e0c998717472cd8806d93741914df" - integrity sha512-rEr8/BrpSN2QmnTw6MuT0WJA/qx54xDqSXG6EBGt37fn7jLCrKYF37GW3xZCdktO0V53l1XF2ssBtmLL+OI2ww== +vue-tsc@0.34.7: + version "0.34.7" + resolved "https://registry.yarnpkg.com/vue-tsc/-/vue-tsc-0.34.7.tgz#b77f79598ff561979db352ad2cdc19b5e35de3ac" + integrity sha512-GcdwGuddEakVBHKw7uiZUfHqobGD4Ym2XExGuwYuxw7rT50ZnRZvYQ3IB7zyPLa7UZEmiy6HTJiTrArw7ZOu+w== dependencies: - "@volar/vue-typescript" "0.34.6" + "@volar/vue-typescript" "0.34.7" vue@3.2.32: version "3.2.32" From eb8284530eacd36ce5435fccffe9d45a761b503f Mon Sep 17 00:00:00 2001 From: freakzlike Date: Tue, 19 Apr 2022 03:57:02 +0200 Subject: [PATCH 10/18] fix: disable stubs for built-in components on shallow (#1409) * fix: disable stubs for built-in components on shallow * fix: wrong import of BaseTransition --- src/stubs.ts | 20 ++- tests/mountingOptions/global.stubs.spec.ts | 188 ++++++++++++++------- 2 files changed, 138 insertions(+), 70 deletions(-) diff --git a/src/stubs.ts b/src/stubs.ts index 5e94654b2..cf3977815 100644 --- a/src/stubs.ts +++ b/src/stubs.ts @@ -2,6 +2,7 @@ import { transformVNodeArgs, Transition, TransitionGroup, + BaseTransition, Teleport, h, defineComponent, @@ -157,7 +158,12 @@ export function stubComponents( const type = nodeType as VNodeTypes | typeof Teleport // stub transition by default via config.global.stubs - if (type === Transition && 'transition' in stubs && stubs['transition']) { + if ( + (type === Transition || type === BaseTransition) && + 'transition' in stubs + ) { + if (stubs.transition === false) return args + return [ createStub({ name: 'transition', @@ -169,11 +175,9 @@ export function stubComponents( } // stub transition-group by default via config.global.stubs - if ( - type === TransitionGroup && - 'transition-group' in stubs && - stubs['transition-group'] - ) { + if (type === TransitionGroup && 'transition-group' in stubs) { + if (stubs['transition-group'] === false) return args + return [ createStub({ name: 'transition-group', @@ -185,7 +189,9 @@ export function stubComponents( } // stub teleport by default via config.global.stubs - if (type === Teleport && 'teleport' in stubs && stubs['teleport']) { + if (type === Teleport && 'teleport' in stubs) { + if (stubs.teleport === false) return args + return [ createStub({ name: 'teleport', diff --git a/tests/mountingOptions/global.stubs.spec.ts b/tests/mountingOptions/global.stubs.spec.ts index c23d4ecfc..0f44ac36c 100644 --- a/tests/mountingOptions/global.stubs.spec.ts +++ b/tests/mountingOptions/global.stubs.spec.ts @@ -392,87 +392,149 @@ describe('mounting options: stubs', () => { ) }) - it('stubs transition by default', () => { - const Comp = { - template: `
` - } - const wrapper = mount(Comp) + describe('transition', () => { + it('stubs transition by default', () => { + const Comp = { + template: `
` + } + const wrapper = mount(Comp) - expect(wrapper.html()).toBe( - '\n' + - '
\n' + - '
' - ) - }) + expect(wrapper.html()).toBe( + '\n' + + '
\n' + + '
' + ) + }) - it('opts out of stubbing transition by default', () => { - const Comp = { - template: `
` - } - const wrapper = mount(Comp, { - global: { - stubs: { - transition: false - } + it('opts out of stubbing transition by default', () => { + const Comp = { + template: `
` } + const wrapper = mount(Comp, { + global: { + stubs: { + transition: false + } + } + }) + + // Vue removes at run-time and does it's magic, so should not + // appear in the html when it isn't stubbed. + expect(wrapper.html()).toBe('
') }) - // Vue removes at run-time and does it's magic, so should not - // appear in the html when it isn't stubbed. - expect(wrapper.html()).toBe('
') + it('does not stub transition on shallow with false', () => { + const Comp = { + template: `
` + } + const wrapper = mount(Comp, { + shallow: true, + global: { + stubs: { + transition: false + } + } + }) + + // Vue removes at run-time and does it's magic, so should not + // appear in the html when it isn't stubbed. + expect(wrapper.html()).toBe('
') + }) }) - it('opts out of stubbing transition-group by default', () => { - const Comp = { - template: `
` - } - const wrapper = mount(Comp, { - global: { - stubs: { - 'transition-group': false - } + describe('transition-group', () => { + it('stubs transition-group by default', () => { + const Comp = { + template: `
` } + const wrapper = mount(Comp) + expect(wrapper.find('#content').exists()).toBe(true) }) - // Vue removes at run-time and does it's magic, so should not - // appear in the html when it isn't stubbed. - expect(wrapper.html()).toBe('
') - }) + it('opts out of stubbing transition-group by default', () => { + const Comp = { + template: `
` + } + const wrapper = mount(Comp, { + global: { + stubs: { + 'transition-group': false + } + } + }) - it('stubs transition-group by default', () => { - const Comp = { - template: `
` - } - const wrapper = mount(Comp) - expect(wrapper.find('#content').exists()).toBe(true) - }) + // Vue removes at run-time and does it's magic, so should not + // appear in the html when it isn't stubbed. + expect(wrapper.html()).toBe('
') + }) - it('does not stub teleport by default', () => { - const Comp = { - template: `
` - } - const wrapper = mount(Comp) + it('does not stub transition-group on shallow with false', () => { + const Comp = { + template: `
` + } + const wrapper = mount(Comp, { + shallow: true, + global: { + stubs: { + 'transition-group': false + } + } + }) - expect(wrapper.html()).toBe( - '\n' + '' - ) + // Vue removes at run-time and does it's magic, so should not + // appear in the html when it isn't stubbed. + expect(wrapper.html()).toBe('
') + }) }) - it('opts in to stubbing teleport ', () => { - const Comp = { - template: `
` - } - const wrapper = mount(Comp, { - global: { - stubs: { - teleport: true - } + describe('teleport', () => { + it('does not stub teleport by default', () => { + const Comp = { + template: `
` } + const wrapper = mount(Comp) + + expect(wrapper.html()).toBe( + '\n' + '' + ) }) - expect(wrapper.html()).toBe( - '\n' + '
\n' + '
' - ) + it('opts in to stubbing teleport ', () => { + const Comp = { + template: `
` + } + const wrapper = mount(Comp, { + global: { + stubs: { + teleport: true + } + } + }) + + expect(wrapper.html()).toBe( + '\n' + + '
\n' + + '
' + ) + }) + + it('does not stub teleport with shallow', () => { + const Comp = { + template: `
` + } + const wrapper = mount(Comp, { + shallow: true, + global: { + stubs: { + teleport: false + } + } + }) + + expect(wrapper.html()).toBe( + '\n' + '' + ) + }) }) it('stubs component by key prior before name', () => { From 4551f19d07eeceacf421930df1ba34f293747a36 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 19 Apr 2022 13:28:28 +1000 Subject: [PATCH 11/18] chore(deps-dev): bump @typescript-eslint/eslint-plugin (#1438) Bumps [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) from 5.19.0 to 5.20.0. - [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases) - [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/CHANGELOG.md) - [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v5.20.0/packages/eslint-plugin) --- updated-dependencies: - dependency-name: "@typescript-eslint/eslint-plugin" dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- yarn.lock | 74 ++++++++++++++-------------------------------------- 2 files changed, 21 insertions(+), 55 deletions(-) diff --git a/package.json b/package.json index 48965ef5b..90527640d 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "@types/jest": "27.4.1", "@types/node": "17.0.25", "@types/pretty": "^2.0.1", - "@typescript-eslint/eslint-plugin": "^5.19.0", + "@typescript-eslint/eslint-plugin": "^5.20.0", "@typescript-eslint/parser": "^5.20.0", "@vue/babel-plugin-jsx": "^1.1.1", "@vue/compat": "3.2.32", diff --git a/yarn.lock b/yarn.lock index 781224e99..b26ed6cfe 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1597,14 +1597,14 @@ dependencies: "@types/yargs-parser" "*" -"@typescript-eslint/eslint-plugin@^5.19.0": - version "5.19.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.19.0.tgz#9608a4b6d0427104bccf132f058cba629a6553c0" - integrity sha512-w59GpFqDYGnWFim9p6TGJz7a3qWeENJuAKCqjGSx+Hq/bwq3RZwXYqy98KIfN85yDqz9mq6QXiY5h0FjGQLyEg== - dependencies: - "@typescript-eslint/scope-manager" "5.19.0" - "@typescript-eslint/type-utils" "5.19.0" - "@typescript-eslint/utils" "5.19.0" +"@typescript-eslint/eslint-plugin@^5.20.0": + version "5.20.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.20.0.tgz#022531a639640ff3faafaf251d1ce00a2ef000a1" + integrity sha512-fapGzoxilCn3sBtC6NtXZX6+P/Hef7VDbyfGqTTpzYydwhlkevB+0vE0EnmHPVTVSy68GUncyJ/2PcrFBeCo5Q== + dependencies: + "@typescript-eslint/scope-manager" "5.20.0" + "@typescript-eslint/type-utils" "5.20.0" + "@typescript-eslint/utils" "5.20.0" debug "^4.3.2" functional-red-black-tree "^1.0.1" ignore "^5.1.8" @@ -1622,14 +1622,6 @@ "@typescript-eslint/typescript-estree" "5.20.0" debug "^4.3.2" -"@typescript-eslint/scope-manager@5.19.0": - version "5.19.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.19.0.tgz#97e59b0bcbcb54dbcdfba96fc103b9020bbe9cb4" - integrity sha512-Fz+VrjLmwq5fbQn5W7cIJZ066HxLMKvDEmf4eu1tZ8O956aoX45jAuBB76miAECMTODyUxH61AQM7q4/GOMQ5g== - dependencies: - "@typescript-eslint/types" "5.19.0" - "@typescript-eslint/visitor-keys" "5.19.0" - "@typescript-eslint/scope-manager@5.20.0": version "5.20.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.20.0.tgz#79c7fb8598d2942e45b3c881ced95319818c7980" @@ -1638,38 +1630,20 @@ "@typescript-eslint/types" "5.20.0" "@typescript-eslint/visitor-keys" "5.20.0" -"@typescript-eslint/type-utils@5.19.0": - version "5.19.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-5.19.0.tgz#80f2125b0dfe82494bbae1ea99f1c0186d420282" - integrity sha512-O6XQ4RI4rQcBGshTQAYBUIGsKqrKeuIOz9v8bckXZnSeXjn/1+BDZndHLe10UplQeJLXDNbaZYrAytKNQO2T4Q== +"@typescript-eslint/type-utils@5.20.0": + version "5.20.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-5.20.0.tgz#151c21cbe9a378a34685735036e5ddfc00223be3" + integrity sha512-WxNrCwYB3N/m8ceyoGCgbLmuZwupvzN0rE8NBuwnl7APgjv24ZJIjkNzoFBXPRCGzLNkoU/WfanW0exvp/+3Iw== dependencies: - "@typescript-eslint/utils" "5.19.0" + "@typescript-eslint/utils" "5.20.0" debug "^4.3.2" tsutils "^3.21.0" -"@typescript-eslint/types@5.19.0": - version "5.19.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.19.0.tgz#12d3d600d754259da771806ee8b2c842d3be8d12" - integrity sha512-zR1ithF4Iyq1wLwkDcT+qFnhs8L5VUtjgac212ftiOP/ZZUOCuuF2DeGiZZGQXGoHA50OreZqLH5NjDcDqn34w== - "@typescript-eslint/types@5.20.0": version "5.20.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.20.0.tgz#fa39c3c2aa786568302318f1cb51fcf64258c20c" integrity sha512-+d8wprF9GyvPwtoB4CxBAR/s0rpP25XKgnOvMf/gMXYDvlUC3rPFHupdTQ/ow9vn7UDe5rX02ovGYQbv/IUCbg== -"@typescript-eslint/typescript-estree@5.19.0": - version "5.19.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.19.0.tgz#fc987b8f62883f9ea6a5b488bdbcd20d33c0025f" - integrity sha512-dRPuD4ocXdaE1BM/dNR21elSEUPKaWgowCA0bqJ6YbYkvtrPVEvZ+zqcX5a8ECYn3q5iBSSUcBBD42ubaOp0Hw== - dependencies: - "@typescript-eslint/types" "5.19.0" - "@typescript-eslint/visitor-keys" "5.19.0" - debug "^4.3.2" - globby "^11.0.4" - is-glob "^4.0.3" - semver "^7.3.5" - tsutils "^3.21.0" - "@typescript-eslint/typescript-estree@5.20.0": version "5.20.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.20.0.tgz#ab73686ab18c8781bbf249c9459a55dc9417d6b0" @@ -1683,26 +1657,18 @@ semver "^7.3.5" tsutils "^3.21.0" -"@typescript-eslint/utils@5.19.0": - version "5.19.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.19.0.tgz#fe87f1e3003d9973ec361ed10d36b4342f1ded1e" - integrity sha512-ZuEckdupXpXamKvFz/Ql8YnePh2ZWcwz7APICzJL985Rp5C2AYcHO62oJzIqNhAMtMK6XvrlBTZeNG8n7gS3lQ== +"@typescript-eslint/utils@5.20.0": + version "5.20.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.20.0.tgz#b8e959ed11eca1b2d5414e12417fd94cae3517a5" + integrity sha512-lHONGJL1LIO12Ujyx8L8xKbwWSkoUKFSO+0wDAqGXiudWB2EO7WEUT+YZLtVbmOmSllAjLb9tpoIPwpRe5Tn6w== dependencies: "@types/json-schema" "^7.0.9" - "@typescript-eslint/scope-manager" "5.19.0" - "@typescript-eslint/types" "5.19.0" - "@typescript-eslint/typescript-estree" "5.19.0" + "@typescript-eslint/scope-manager" "5.20.0" + "@typescript-eslint/types" "5.20.0" + "@typescript-eslint/typescript-estree" "5.20.0" eslint-scope "^5.1.1" eslint-utils "^3.0.0" -"@typescript-eslint/visitor-keys@5.19.0": - version "5.19.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.19.0.tgz#c84ebc7f6c744707a361ca5ec7f7f64cd85b8af6" - integrity sha512-Ym7zZoMDZcAKWsULi2s7UMLREdVQdScPQ/fKWMYefarCztWlHPFVJo8racf8R0Gc8FAEJ2eD4of8As1oFtnQlQ== - dependencies: - "@typescript-eslint/types" "5.19.0" - eslint-visitor-keys "^3.0.0" - "@typescript-eslint/visitor-keys@5.20.0": version "5.20.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.20.0.tgz#70236b5c6b67fbaf8b2f58bf3414b76c1e826c2a" From 0d63f35425141c23293d999bd2c47b9ddbd756d5 Mon Sep 17 00:00:00 2001 From: freakzlike Date: Tue, 19 Apr 2022 05:29:14 +0200 Subject: [PATCH 12/18] docs: Add type info about WrapperLike on findComponent (#1436) --- docs/api/index.md | 27 ++++++++++++++++++++--- docs/guide/advanced/component-instance.md | 11 +++++++++ 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/docs/api/index.md b/docs/api/index.md index d3fd11000..a5826c6e2 100644 --- a/docs/api/index.md +++ b/docs/api/index.md @@ -1096,8 +1096,12 @@ Finds a Vue Component instance and returns a `VueWrapper` if found. Returns `Err **Signature:** ```ts -findComponent(selector: new () => T): VueWrapper -findComponent(selector: FindComponentSelector): VueWrapper +findComponent(selector: string): WrapperLike +findComponent(selector: T | Exclude): VueWrapper> +findComponent(selector: T | string): DOMWrapper +findComponent(selector: NameSelector | RefSelector): VueWrapper +findComponent(selector: T | FindComponentSelector): VueWrapper +findComponent(selector: FindComponentSelector): WrapperLike ``` **Details:** @@ -1194,12 +1198,29 @@ expect(childByCss.vm.$options.name).toBe('Root') // => still Root The reason for such behavior is that `RootComponent` and `ChildComponent` are sharing same DOM node and only first matching component is included for each unique DOM node ::: +:::info WrapperLike type when using CSS selector +When using `wrapper.findComponent('.foo')` for example then VTU will return the `WrapperLike` type. This is because functional components +would need a `DOMWrapper` otherwise a `VueWrapper`. You can force to return a `VueWrapper` by providing the correct component type: + +```typescript +wrapper.findComponent('.foo') // returns WrapperLike +wrapper.findComponent('.foo') // returns VueWrapper +wrapper.findComponent('.foo') // returns VueWrapper +``` +::: + ### findAllComponents **Signature:** ```ts -findAllComponents(selector: { name: string } | string): VueWrapper[] +findAllComponents(selector: string): WrapperLike[] +findAllComponents(selector: T | Exclude): VueWrapper>[] +findAllComponents(selector: string): DOMWrapper[] +findAllComponents(selector: T): DOMWrapper[] +findAllComponents(selector: NameSelector): VueWrapper[] +findAllComponents(selector: T | FindAllComponentsSelector): VueWrapper[] +findAllComponents(selector: FindAllComponentsSelector): WrapperLike[] ``` **Details:** diff --git a/docs/guide/advanced/component-instance.md b/docs/guide/advanced/component-instance.md index 454a88c67..5bdc70666 100644 --- a/docs/guide/advanced/component-instance.md +++ b/docs/guide/advanced/component-instance.md @@ -72,6 +72,17 @@ A more thorough way to test this would be asserting against the rendered content Note: if you are using a `