Skip to content

Commit 7e1882a

Browse files
authored
feat: Rename setProps to rerender (#174)
* Suggest update when using fireEvent.input or fireEvent.change * Rename setProps to rerender. * Remove travis in favor on GH Action. We're already using it in master, and deployment won't work unless we leverage actions here, too.
1 parent ebe23d8 commit 7e1882a

14 files changed

+287
-98
lines changed

.eslintrc.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
module.exports = {
22
extends: [
33
'./node_modules/kcd-scripts/eslint.js',
4-
'plugin:vue/recommended',
4+
'plugin:vue/vue3-recommended',
5+
'plugin:testing-library/vue',
56
'prettier/vue',
67
],
78
plugins: ['vue'],
@@ -12,5 +13,6 @@ module.exports = {
1213
'testing-library/no-dom-import': 'off',
1314
'testing-library/prefer-screen-queries': 'off',
1415
'testing-library/no-manual-cleanup': 'off',
16+
'testing-library/no-await-sync-events': 'off',
1517
},
1618
}

.github/workflows/validate.yml

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: validate
2+
on:
3+
push:
4+
branches:
5+
[
6+
'+([0-9])?(.{+([0-9]),x}).x',
7+
'master',
8+
'next',
9+
'next-major',
10+
'beta',
11+
'alpha',
12+
'!all-contributors/**',
13+
]
14+
pull_request:
15+
branches-ignore: ['all-contributors/**']
16+
jobs:
17+
main:
18+
strategy:
19+
matrix:
20+
node: [10.13, 12, 14]
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: ⬇️ Checkout repo
24+
uses: actions/checkout@v2
25+
26+
- name: ⎔ Setup node
27+
uses: actions/setup-node@v1
28+
with:
29+
node-version: ${{ matrix.node }}
30+
31+
- name: 📥 Download deps
32+
uses: bahmutov/npm-install@v1
33+
with:
34+
useLockFile: false
35+
36+
- name: ▶️ Run validate script
37+
run: npm run validate
38+
39+
- name: ⬆️ Upload coverage report
40+
uses: codecov/codecov-action@v1
41+
42+
release:
43+
needs: main
44+
runs-on: ubuntu-latest
45+
if:
46+
${{ github.repository == 'testing-library/vue-testing-library' &&
47+
contains('refs/heads/master,refs/heads/beta,refs/heads/next,refs/heads/alpha',
48+
github.ref) && github.event_name == 'push' }}
49+
steps:
50+
- name: ⬇️ Checkout repo
51+
uses: actions/checkout@v2
52+
53+
- name: ⎔ Setup node
54+
uses: actions/setup-node@v1
55+
with:
56+
node-version: 14
57+
58+
- name: 📥 Download deps
59+
uses: bahmutov/npm-install@v1
60+
with:
61+
useLockFile: false
62+
63+
- name: 🏗 Run build script
64+
run: npm run build
65+
66+
- name: 🚀 Release
67+
uses: cycjimmy/semantic-release-action@v2
68+
with:
69+
semantic_version: 17
70+
branches: |
71+
[
72+
'+([0-9])?(.{+([0-9]),x}).x',
73+
'master',
74+
'next',
75+
'next-major',
76+
{name: 'beta', prerelease: true},
77+
{name: 'alpha', prerelease: true}
78+
]
79+
env:
80+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
81+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

.travis.yml

-28
This file was deleted.

README.md

+7-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div align="center">
2-
<h1>Vue Testing Library</h1>
2+
<h1>Vue Testing Library for Vue 3</h1>
33

44
<br />
55

@@ -32,7 +32,6 @@
3232
[![GitHub version][github-badge]][github]
3333
[![npm version][npm-badge]][npm]
3434
[![Discord][discord-badge]][discord]
35-
3635
[![MIT License][license-badge]][license]
3736
<!-- prettier-ignore-end -->
3837

@@ -66,7 +65,7 @@ project's `devDependencies`:
6665
npm install --save-dev @testing-library/vue
6766
```
6867

69-
This library has `peerDependencies` listings for `Vue` and
68+
This library has `peerDependencies` listings for `Vue 3` and
7069
`vue-template-compiler`.
7170

7271
You may also be interested in installing `jest-dom` so you can use [the custom
@@ -76,10 +75,8 @@ Jest matchers][jest-dom].
7675

7776
```html
7877
<template>
79-
<div>
80-
<p>Times clicked: {{ count }}</p>
81-
<button @click="increment">increment</button>
82-
</div>
78+
<p>Times clicked: {{ count }}</p>
79+
<button @click="increment">increment</button>
8380
</template>
8481

8582
<script>
@@ -235,10 +232,11 @@ instead of filing an issue on GitHub.
235232
[![mediafreakch](https://avatars2.githubusercontent.com/u/777093?v=3&s=120)](https://github.com/mediafreakch)
236233
[![afenton90](https://avatars2.githubusercontent.com/u/8963736?v=3&s=120)](https://github.com/afenton90)
237234
[![cilice](https://avatars2.githubusercontent.com/u/835588?v=3&s=120)](https://github.com/cilice)
235+
[![ITenthusiasm](https://avatars2.githubusercontent.com/u/47364027?v3&s=120)](https://github.com/ITenthusiasm)
238236

239237
<!-- prettier-ignore-start -->
240-
[build-badge]: https://travis-ci.org/testing-library/vue-testing-library.svg?branch=master
241-
[build]: https://travis-ci.org/testing-library/vue-testing-library
238+
[build-badge]: https://img.shields.io/github/workflow/status/testing-library/vue-testing-library/validate?logo=github
239+
[build]: https://github.com/testing-library/vue-testing-library/actions?query=workflow%3Avalidate
242240
[coverage-badge]: https://img.shields.io/codecov/c/github/testing-library/vue-testing-library.svg
243241
[coverage]: https://codecov.io/github/testing-library/vue-testing-library
244242
[github-badge]: https://badge.fury.io/gh/testing-library%2Fvue-testing-library.svg

package.json

+7-7
Original file line numberDiff line numberDiff line change
@@ -46,27 +46,27 @@
4646
"dependencies": {
4747
"@babel/runtime": "^7.12.1",
4848
"@testing-library/dom": "^7.26.3",
49-
"@types/testing-library__vue": "*",
50-
"@vue/test-utils": "^2.0.0-beta.7",
49+
"@vue/test-utils": "^2.0.0-beta.10",
5150
"lodash.merge": "^4.6.2"
5251
},
5352
"devDependencies": {
5453
"@babel/plugin-transform-runtime": "^7.12.1",
5554
"@testing-library/jest-dom": "^5.11.5",
55+
"@testing-library/user-event": "^12.2.2",
5656
"@vue/compiler-sfc": "^3.0.2",
5757
"apollo-boost": "^0.4.9",
5858
"apollo-cache-inmemory": "^1.6.6",
5959
"apollo-client": "^2.6.10",
6060
"axios": "^0.20.0",
61-
"eslint-plugin-vue": "^6.2.2",
61+
"eslint-plugin-vue": "^7.1.0",
6262
"graphql": "^15.4.0",
6363
"graphql-tag": "^2.11.0",
6464
"isomorphic-unfetch": "^3.1.0",
6565
"jest-serializer-vue": "^2.0.2",
66-
"kcd-scripts": "^6.6.0",
66+
"kcd-scripts": "^7.0.3",
6767
"msw": "^0.21.3",
6868
"portal-vue": "^2.1.7",
69-
"typescript": "^3.8.3",
69+
"typescript": "^4.1.2",
7070
"vee-validate": "^4.0.0-beta.16",
7171
"vue": "^3.0.2",
7272
"vue-apollo": "^3.0.5",
@@ -77,8 +77,8 @@
7777
"vuex": "^4.0.0-rc.1"
7878
},
7979
"peerDependencies": {
80-
"vue": "^3.0",
81-
"@vue/compiler-sfc": "^3.0"
80+
"vue": ">= 3",
81+
"@vue/compiler-sfc": ">= 3"
8282
},
8383
"husky": {
8484
"hooks": {

src/__tests__/components/Button.vue

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ export default {
77
props: {
88
text: {
99
type: String,
10-
default: 'Button Text'
11-
}
10+
default: 'Button Text',
11+
},
1212
},
1313
methods: {
1414
handleClick(e) {
1515
this.$emit('click')
16-
}
17-
}
16+
},
17+
},
1818
}
1919
</script>

src/__tests__/components/Form.vue

+35-36
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,42 @@
11
<template>
2-
<div>
3-
<h1>Movie Review</h1>
4-
<form onsubmit="return false">
5-
<label for="movie-input">Title of the movie</label>
6-
<input id="movie-input" v-model="title" name="title" />
2+
<h1>Movie Review</h1>
3+
<form @submit.prevent="submit">
4+
<label for="movie-input">Title of the movie</label>
5+
<input id="movie-input" v-model="title" name="title" />
76

8-
<label id="review-textarea">Your review</label>
9-
<textarea
10-
v-model="review"
11-
name="review-textarea"
12-
placeholder="Write an awesome review"
13-
aria-labelledby="review-textarea"
14-
/>
7+
<label id="review-textarea">Your review</label>
8+
<textarea
9+
v-model="review"
10+
name="review-textarea"
11+
placeholder="Write an awesome review"
12+
aria-labelledby="review-textarea"
13+
/>
1514

16-
<label>
17-
<input v-model="rating" type="radio" value="3" />
18-
Wonderful
19-
</label>
20-
<label>
21-
<input v-model="rating" type="radio" value="2" />
22-
Average
23-
</label>
24-
<label>
25-
<input v-model="rating" type="radio" value="1" />
26-
Awful
27-
</label>
15+
<label>
16+
<input v-model="rating" type="radio" value="3" />
17+
Wonderful
18+
</label>
19+
<label>
20+
<input v-model="rating" type="radio" value="2" />
21+
Average
22+
</label>
23+
<label>
24+
<input v-model="rating" type="radio" value="1" />
25+
Awful
26+
</label>
2827

29-
<label id="recommend-label">Would you recommend this movie?</label>
30-
<input
31-
id="recommend"
32-
v-model="recommend"
33-
type="checkbox"
34-
name="recommend"
35-
/>
28+
<label id="recommend-label" for="recommend">
29+
Would you recommend this movie?
30+
</label>
31+
<input
32+
id="recommend"
33+
v-model="recommend"
34+
type="checkbox"
35+
name="recommend"
36+
/>
3637

37-
<button :disabled="submitDisabled" type="submit" @click="submit">
38-
Submit
39-
</button>
40-
</form>
41-
</div>
38+
<button :disabled="submitDisabled" type="submit">Submit</button>
39+
</form>
4240
</template>
4341

4442
<script>
@@ -51,6 +49,7 @@ export default {
5149
recommend: false,
5250
}
5351
},
52+
5453
computed: {
5554
submitDisabled() {
5655
return !this.title || !this.review
+6-8
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
<template>
2-
<div>
3-
<span data-testid="number-display">{{ number }}</span>
4-
<span data-testid="instance-id">{{ id }}</span>
5-
</div>
2+
<span data-testid="number-display">{{ number }}</span>
3+
<span data-testid="instance-id">{{ id }}</span>
64
</template>
75

86
<script>
@@ -12,13 +10,13 @@ export default {
1210
props: {
1311
number: {
1412
type: Number,
15-
required: true
16-
}
13+
required: true,
14+
},
1715
},
1816
data() {
1917
return {
20-
id: idCounter++
18+
id: idCounter++,
2119
}
22-
}
20+
},
2321
}
2422
</script>

src/__tests__/components/Select.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
export default {
1919
data() {
2020
return {
21-
selectedDino: 'dino1'
21+
selectedDino: 'dino1',
2222
}
23-
}
23+
},
2424
}
2525
</script>

src/__tests__/debug.js

+16
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,19 @@ test('debug pretty prints multiple nodes with the given parameter', () => {
5757
expect.stringContaining('Lorem ipsum dolor sit amet'),
5858
)
5959
})
60+
61+
test('allows same arguments as prettyDOM', () => {
62+
const {debug, container} = render(HelloWorld)
63+
64+
// debug accepts a maxLength and an options parameters:
65+
// https://testing-library.com/docs/dom-testing-library/api-helpers#prettydom
66+
debug(container, 6, {highlight: false})
67+
68+
expect(console.log).toHaveBeenCalledTimes(1)
69+
expect(console.log.mock.calls[0]).toMatchInlineSnapshot(`
70+
Array [
71+
<div>
72+
...,
73+
]
74+
`)
75+
})

0 commit comments

Comments
 (0)