Skip to content

Commit 0e2aa0a

Browse files
authored
Merge pull request #79 from testing-library/update-deps
Update deps
2 parents b98df9b + f611dce commit 0e2aa0a

File tree

5 files changed

+46
-33
lines changed

5 files changed

+46
-33
lines changed

package-lock.json

+26-17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"author": "Daniel Cook",
3232
"license": "MIT",
3333
"dependencies": {
34-
"@testing-library/dom": "^5.6.0",
34+
"@testing-library/dom": "^6.0.0",
3535
"@vue/test-utils": "^1.0.0-beta.29"
3636
},
3737
"devDependencies": {
@@ -55,17 +55,17 @@
5555
"eslint-plugin-promise": "^4.2.1",
5656
"eslint-plugin-standard": "^4.0.0",
5757
"eslint-plugin-vue": "^5.2.3",
58-
"husky": "^3.0.2",
58+
"husky": "^3.0.3",
5959
"jest": "^24.8.0",
6060
"jest-in-case": "^1.0.2",
6161
"jest-serializer-vue": "^2.0.2",
6262
"lint-staged": "^9.2.1",
6363
"prettier": "^1.18.2",
6464
"vee-validate": "^2.2.13",
6565
"vue": "^2.6.10",
66-
"vue-i18n": "^8.12.0",
66+
"vue-i18n": "^8.13.0",
6767
"vue-jest": "^3.0.4",
68-
"vue-router": "^3.0.7",
68+
"vue-router": "^3.1.2",
6969
"vue-template-compiler": "^2.6.10",
7070
"vuex": "^3.1.1"
7171
},

src/vue-testing-library.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { createLocalVue, mount } from '@vue/test-utils'
22

33
import {
44
getQueriesForElement,
5-
prettyDOM,
5+
logDOM,
66
wait,
77
fireEvent
88
} from '@testing-library/dom'
@@ -63,7 +63,7 @@ function render(
6363
return {
6464
container: wrapper.element.parentNode,
6565
baseElement: document.body,
66-
debug: (el = wrapper.element) => console.log(prettyDOM(el)),
66+
debug: (el = wrapper.element) => logDOM(el),
6767
unmount: () => wrapper.destroy(),
6868
isUnmounted: () => wrapper.vm._isDestroyed,
6969
html: () => wrapper.html(),

tests/__tests__/form.js

+6-7
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ test('Review form submits', async () => {
1111
const fakeReview = {
1212
title: 'An Awesome Movie',
1313
review: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
14-
rating: '3',
15-
recommend: true
14+
rating: '3'
1615
}
1716

1817
const {
@@ -46,7 +45,7 @@ test('Review form submits', async () => {
4645
expect(ratingSelect.checked).toBe(true)
4746
expect(initiallySelectedInput.checked).toBe(false)
4847

49-
// Get the Input element by its implicit ARIA role.
48+
// Get the Input element by its implicit ARIA role
5049
const recommendInput = getByRole('checkbox')
5150

5251
expect(recommendInput.checked).toBe(false)
@@ -56,13 +55,13 @@ test('Review form submits', async () => {
5655
// NOTE: in jsdom, it's not possible to trigger a form submission
5756
// by clicking on the submit button. This is really unfortunate.
5857
// So the next best thing is to fireEvent a submit on the form itself
59-
// then ensure that there's a submit button.
58+
// then ensure that there's a submit button
6059
expect(submitButton).toBeEnabled()
6160
expect(submitButton).toHaveAttribute('type', 'submit')
6261

6362
await fireEvent.click(submitButton)
6463

65-
// Assert event has been emitted.
66-
expect(emitted().submit).toHaveLength(1)
67-
expect(emitted().submit[0]).toEqual([fakeReview])
64+
// Assert event has been emitted
65+
expect(emitted()).toHaveProperty('submit')
66+
expect(emitted().submit[0][0]).toMatchObject(fakeReview)
6867
})

tests/__tests__/simple-button.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ test('renders button with text', () => {
1212
props: { text }
1313
})
1414

15-
expect(getByRole('button')).toHaveTextContent(text)
15+
// Get the only element with a 'button' role
16+
const button = getByRole('button')
17+
18+
expect(button).toHaveTextContent(text)
1619
})
1720

1821
test('click event is emitted when button is clicked', async () => {
@@ -22,8 +25,10 @@ test('click event is emitted when button is clicked', async () => {
2225
props: { text }
2326
})
2427

25-
// Send a click event to the element with a 'button' role
28+
// Send a click event
2629
await fireEvent.click(getByRole('button'))
2730

28-
expect(emitted().click).toHaveLength(1)
31+
// Expect that the event emitted a "click" event. We should test for emitted
32+
// events has they are part of the public API of the component
33+
expect(emitted()).toHaveProperty('click')
2934
})

0 commit comments

Comments
 (0)