diff --git a/package.json b/package.json index d579d2f3..273dd82a 100644 --- a/package.json +++ b/package.json @@ -35,44 +35,50 @@ "vue.js 2", "vue.js 2 testing", "vue 2", - "vue 2 testing" + "vue 2 testing", + "vue.js 3", + "vue.js 3 testing", + "vue 3", + "vue 3 testing" ], "author": "Daniel Cook", "license": "MIT", "dependencies": { - "@babel/runtime": "^7.11.2", - "@testing-library/dom": "^7.24.3", - "@types/testing-library__vue": "^5.0.0", - "@vue/test-utils": "^1.1.0" + "@babel/runtime": "^7.12.1", + "@testing-library/dom": "^7.26.3", + "@types/testing-library__vue": "*", + "@vue/test-utils": "^2.0.0-beta.7", + "lodash.merge": "^4.6.2" }, "devDependencies": { - "@babel/plugin-transform-runtime": "^7.11.5", - "@testing-library/jest-dom": "^5.11.4", + "@babel/plugin-transform-runtime": "^7.12.1", + "@testing-library/jest-dom": "^5.11.5", + "@vue/compiler-sfc": "^3.0.2", "apollo-boost": "^0.4.9", "apollo-cache-inmemory": "^1.6.6", + "apollo-client": "^2.6.10", "axios": "^0.20.0", "eslint-plugin-vue": "^6.2.2", - "graphql": "^15.3.0", + "graphql": "^15.4.0", "graphql-tag": "^2.11.0", - "isomorphic-unfetch": "^3.0.0", + "isomorphic-unfetch": "^3.1.0", "jest-serializer-vue": "^2.0.2", - "kcd-scripts": "^6.5.1", - "lodash.merge": "^4.6.2", - "msw": "^0.21.2", + "kcd-scripts": "^6.6.0", + "msw": "^0.21.3", "portal-vue": "^2.1.7", - "vee-validate": "^2.2.15", - "vue": "^2.6.12", - "vue-apollo": "^3.0.4", - "vue-i18n": "^8.21.1", - "vue-jest": "^4.0.0-rc.0", - "vue-router": "^3.4.5", - "vue-template-compiler": "^2.6.12", - "vuetify": "^2.3.10", - "vuex": "^3.5.1" + "typescript": "^3.8.3", + "vee-validate": "^4.0.0-beta.16", + "vue": "^3.0.2", + "vue-apollo": "^3.0.5", + "vue-i18n": "^9.0.0-beta.6", + "vue-jest": "^5.0.0-alpha.5", + "vue-router": "^4.0.0-rc.1", + "vuetify": "^2.3.16", + "vuex": "^4.0.0-rc.1" }, "peerDependencies": { - "vue": "^2.6.10", - "vue-template-compiler": "^2.6.10" + "vue": "^3.0", + "@vue/compiler-sfc": "^3.0" }, "husky": { "hooks": { diff --git a/src/__tests__/auto-cleanup.js b/src/__tests__/auto-cleanup.js index 8d5412ae..8255c083 100644 --- a/src/__tests__/auto-cleanup.js +++ b/src/__tests__/auto-cleanup.js @@ -1,12 +1,11 @@ import {render} from '@testing-library/vue' import '@testing-library/jest-dom' -// This just verifies that by importing VTL in an environment which supports +// This verifies that by importing VTL in an environment which supports // afterEach (like jest) we'll get automatic cleanup between tests. -test('render the first component', () => { - render({ - template: `

Hello World

`, - }) +test('renders the component', () => { + render({template: `

Hello World

`}) + expect(document.body.innerHTML).toMatchInlineSnapshot(`

Hello World

diff --git a/src/__tests__/axios-mock.js b/src/__tests__/axios-mock.js index 39e51bab..c4f066d8 100644 --- a/src/__tests__/axios-mock.js +++ b/src/__tests__/axios-mock.js @@ -4,11 +4,9 @@ import {render, fireEvent} from '@testing-library/vue' import Component from './components/Fetch.vue' test('mocks an API call when load-greeting is clicked', async () => { - axiosMock.get.mockImplementationOnce(() => - Promise.resolve({ - data: {greeting: 'hello there'}, - }), - ) + axiosMock.get.mockResolvedValueOnce({ + data: {greeting: 'hello there'}, + }) const {html, getByText} = render(Component, {props: {url: '/greeting'}}) @@ -22,11 +20,7 @@ test('mocks an API call when load-greeting is clicked', async () => { // that Snapshot Testing should not be treated as a replacement for regular // tests. // More about the topic: https://twitter.com/searls/status/919594505938112512 - expect(html()).toMatchInlineSnapshot(` -
- hello there -
- `) + expect(html()).toMatchInlineSnapshot( + `
hello there
`, + ) }) diff --git a/src/__tests__/cleanup-throw.js b/src/__tests__/cleanup-throw.js index b8ba9fd7..828820f2 100644 --- a/src/__tests__/cleanup-throw.js +++ b/src/__tests__/cleanup-throw.js @@ -1,23 +1,25 @@ -import {render, cleanup} from '@testing-library/vue' -import Vue from 'vue' +test.todo('check if this test still makes sense') -test('cleanup re-throws errors from async lifecycle hooks', async () => { - const err = new Error('foo') - render({ - async mounted() { - await new Promise((resolve, reject) => { - reject(err) - }) - }, - template: `

Hello World

`, - }) - // thrown errors are logged redundantly by vue-test-utils injected Vue.config.errorHandler - // mute console - const spy = jest.spyOn(console, 'error').mockImplementation(() => {}) +// import {render, cleanup} from '@testing-library/vue' +// import {nextTick} from 'vue' - await Vue.nextTick() - expect(cleanup).toThrow(err) +// test('cleanup re-throws errors from async lifecycle hooks', async () => { +// const err = new Error('foo') +// render({ +// async mounted() { +// await new Promise((resolve, reject) => { +// reject(err) +// }) +// }, +// template: `

Hello World

`, +// }) +// // thrown errors are logged redundantly by vue-test-utils injected Vue.config.errorHandler +// // mute console +// const spy = jest.spyOn(console, 'error').mockImplementation(() => {}) - // unmute console - spy.mockReset() -}) +// await nextTick() +// expect(cleanup).toThrow(err) + +// // unmute console +// spy.mockReset() +// }) diff --git a/src/__tests__/components/Card.vue b/src/__tests__/components/Card.vue index 9174e499..c62ee1b4 100644 --- a/src/__tests__/components/Card.vue +++ b/src/__tests__/components/Card.vue @@ -1,22 +1,6 @@ - - diff --git a/src/__tests__/components/Form.vue b/src/__tests__/components/Form.vue index 78b83ca9..809bf316 100644 --- a/src/__tests__/components/Form.vue +++ b/src/__tests__/components/Form.vue @@ -1,73 +1,73 @@ -