Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3ef7112

Browse files
authored
feat: Add types for Vue 3 (#180)
* Add basic types * Rename main file to properly get types * Fix import statement * Fix compiler options lib * Extract temporary-defined types to its own file * Remove duplicate test * Fix link * Improve tests * Remove unnecessary chars * Add support for file inputs * Update deps * Fix rerender typing test * Remove typecheck step until we figure out how to overcome ts-ignore in node_modules. lol * Update deps
1 parent 7e1882a commit 3ef7112

40 files changed

+286
-139
lines changed

‎.eslintrc.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
module.exports = {
2+
parserOptions: {
3+
parser: '@typescript-eslint/parser',
4+
},
25
extends: [
36
'./node_modules/kcd-scripts/eslint.js',
47
'plugin:vue/vue3-recommended',

‎README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,7 @@ light-weight, simple, and understandable.
171171

172172
## Typings
173173

174-
The TypeScript type definitions are in the [DefinitelyTyped repo][types] and
175-
bundled with Vue Testing Library.
174+
The TypeScript type definitions are in the [types][types-directory] directory.
176175

177176
## ESLint support
178177

@@ -247,7 +246,6 @@ instead of filing an issue on GitHub.
247246
[license]: https://github.com/testing-library/vue-testing-library/blob/master/LICENSE
248247
[discord]: https://testing-library.com/discord
249248
[discord-badge]: https://img.shields.io/discord/723559267868737556.svg?label=&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2&style=flat-square
250-
[types]: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/testing-library__vue
251249
[jest-dom]: https://github.com/testing-library/jest-dom
252250
[which-query]: https://testing-library.com/docs/guide-which-query
253251
[guiding-principle]: https://twitter.com/kentcdodds/status/977018512689455106
@@ -261,10 +259,11 @@ instead of filing an issue on GitHub.
261259
[add-issue-bug]: https://github.com/testing-library/vue-testing-library/issues/new?assignees=&labels=bug&template=bug_report.md&title=
262260
[add-issue]: (https://github.com/testing-library/vue-testing-library/issues/new)
263261

262+
[types-directory]: https://github.com/testing-library/vue-testing-library/blob/master/types
264263
[test-directory]: https://github.com/testing-library/vue-testing-library/blob/master/src/__tests__
265264
[vuex-example]: https://github.com/testing-library/vue-testing-library/blob/master/src/__tests__/vuex.js
266265
[vue-router-example]: https://github.com/testing-library/vue-testing-library/blob/master/src/__tests__/vue-router.js
267266
[vee-validate-example]: https://github.com/testing-library/vue-testing-library/blob/master/src/__tests__/validate-plugin.js
268-
[vue-i18n-example]: https://github.com/testing-library/vue-testing-library/blob/master/src/__tests__/vueI18n.js
267+
[vue-i18n-example]: https://github.com/testing-library/vue-testing-library/blob/master/src/__tests__/vue-i18n.js
269268
[vuetify-example]: https://github.com/testing-library/vue-testing-library/blob/master/src/__tests__/vuetify.js
270269
<!-- prettier-ignore-end -->

‎jest.config.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ const config = require('kcd-scripts/jest')
44
module.exports = merge(config, {
55
testEnvironment: 'jsdom',
66
moduleFileExtensions: ['js', 'vue'],
7-
moduleNameMapper: {
8-
'@testing-library/vue': '<rootDir>/src/vue-testing-library.js',
9-
},
107
coverageDirectory: './coverage',
118
collectCoverageFrom: ['**/src/**/*.js', '!**/src/__tests__/**'],
129
transform: {

‎package.json

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"name": "@testing-library/vue",
33
"version": "0.0.0-semantically-released",
44
"description": "Simple and complete Vue DOM testing utilities that encourage good testing practices.",
5-
"main": "dist/vue-testing-library.js",
5+
"main": "dist/index.js",
6+
"types": "types/index.d.ts",
67
"scripts": {
78
"format": "kcd-scripts format",
89
"build": "kcd-scripts build",
@@ -16,6 +17,7 @@
1617
"node": ">10.18"
1718
},
1819
"files": [
20+
"types",
1921
"dist",
2022
"cleanup-after-each.js"
2123
],
@@ -45,36 +47,38 @@
4547
"license": "MIT",
4648
"dependencies": {
4749
"@babel/runtime": "^7.12.1",
48-
"@testing-library/dom": "^7.26.3",
49-
"@vue/test-utils": "^2.0.0-beta.10",
50+
"@testing-library/dom": "^7.28.1",
51+
"@vue/test-utils": "^2.0.0-beta.12",
5052
"lodash.merge": "^4.6.2"
5153
},
5254
"devDependencies": {
5355
"@babel/plugin-transform-runtime": "^7.12.1",
5456
"@testing-library/jest-dom": "^5.11.5",
55-
"@testing-library/user-event": "^12.2.2",
56-
"@vue/compiler-sfc": "^3.0.2",
57+
"@testing-library/user-event": "^12.4.0",
58+
"@types/estree": "0.0.45",
59+
"@vue/compiler-sfc": "^3.0.4",
5760
"apollo-boost": "^0.4.9",
5861
"apollo-cache-inmemory": "^1.6.6",
5962
"apollo-client": "^2.6.10",
6063
"axios": "^0.20.0",
64+
"dtslint": "^4.0.6",
6165
"eslint-plugin-vue": "^7.1.0",
6266
"graphql": "^15.4.0",
6367
"graphql-tag": "^2.11.0",
6468
"isomorphic-unfetch": "^3.1.0",
6569
"jest-serializer-vue": "^2.0.2",
66-
"kcd-scripts": "^7.0.3",
70+
"kcd-scripts": "^7.5.1",
6771
"msw": "^0.21.3",
6872
"portal-vue": "^2.1.7",
6973
"typescript": "^4.1.2",
70-
"vee-validate": "^4.0.0-beta.16",
71-
"vue": "^3.0.2",
74+
"vee-validate": "^4.0.2",
75+
"vue": "^3.0.4",
7276
"vue-apollo": "^3.0.5",
7377
"vue-i18n": "^9.0.0-beta.6",
74-
"vue-jest": "^5.0.0-alpha.5",
75-
"vue-router": "^4.0.0-rc.1",
76-
"vuetify": "^2.3.16",
77-
"vuex": "^4.0.0-rc.1"
78+
"vue-jest": "^5.0.0-alpha.7",
79+
"vue-router": "^4.0.0-rc.6",
80+
"vuetify": "^2.3.19",
81+
"vuex": "^4.0.0-rc.2"
7882
},
7983
"peerDependencies": {
8084
"vue": ">= 3",

‎src/__tests__/auto-cleanup-skip.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
let render
2-
beforeAll(async() => {
2+
beforeAll(() => {
33
process.env.VTL_SKIP_AUTO_CLEANUP = 'true'
4-
const vtl = awaitrequire('@testing-library/vue')
4+
const vtl = require('..')
55
render = vtl.render
66
})
77

‎src/__tests__/auto-cleanup.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {render} from '@testing-library/vue'
1+
import {render} from '..'
22
import '@testing-library/jest-dom'
33

44
// This verifies that by importing VTL in an environment which supports

‎src/__tests__/axios-mock.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import '@testing-library/jest-dom'
22
import axiosMock from 'axios'
3-
import {render, fireEvent} from '@testing-library/vue'
3+
import {render, fireEvent} from '..'
44
import Component from './components/Fetch.vue'
55

66
test('mocks an API call when load-greeting is clicked', async () => {

‎src/__tests__/cleanup-throw.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
test.todo('check if this test still makes sense')
22

3-
// import {render, cleanup} from '@testing-library/vue'
3+
// import {render, cleanup} from '..'
44
// import {nextTick} from 'vue'
55

66
// test('cleanup re-throws errors from async lifecycle hooks', async () => {

‎src/__tests__/components/Translations.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<template>
2-
<h2>{{ $t('hello') }}</h2>
3-
<select v-model="$i18n.locale">
4-
<option value="en">English</option>
5-
<option value="ja">Japanese</option>
6-
</select>
2+
<h2>{{ $t('hello') }}</h2>
3+
<select v-model="$i18n.locale">
4+
<option value="en">English</option>
5+
<option value="ja">Japanese</option>
6+
</select>
77
</template>
88

99
<script>

‎src/__tests__/components/VueI18n.vue

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /