Skip to content

Commit f298de4

Browse files
committed
First commit
0 parents  commit f298de4

23 files changed

+452
-0
lines changed

.babelrc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"presets": [
3+
["env", {
4+
"modules": false,
5+
"targets": {
6+
"browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
7+
}
8+
}]
9+
],
10+
"plugins": [
11+
"transform-object-rest-spread",
12+
"transform-runtime"
13+
],
14+
"env": {
15+
"test": {
16+
"presets": ["env"]
17+
}
18+
}
19+
}

.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
node_modules
2+
coverage
3+
dist
4+
.opt-in
5+
.opt-out
6+
.DS_Store
7+
.eslintcache
8+
9+
# these cause more harm than good
10+
# when working with contributors
11+
package-lock.json
12+
yarn.lock

LICENSE

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
The MIT License (MIT)
2+
Copyright (c) 2018 Daniel Cook
3+
4+
Permission is hereby granted, free of charge, to any person obtaining a copy
5+
of this software and associated documentation files (the "Software"), to deal
6+
in the Software without restriction, including without limitation the rights
7+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
copies of the Software, and to permit persons to whom the Software is
9+
furnished to do so, subject to the following conditions:
10+
11+
The above copyright notice and this permission notice shall be included in all
12+
copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
SOFTWARE.

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<div align="center">
2+
<h1>vue-testing-library</h1>

package.json

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"name": "vue-testing-library",
3+
"version": "1.0.0",
4+
"description": "Simple and completed Vue DOM testing utilities that encourage good testing practices.",
5+
"main": "src/index.js",
6+
"scripts": {
7+
"test": "jest --verbose"
8+
},
9+
"author": "Daniel Cook",
10+
"license": "MIT",
11+
"devDependencies": {
12+
"@vue/test-utils": "^1.0.0-beta.12",
13+
"axios": "^0.18.0",
14+
"babel-core": "^6.26.0",
15+
"babel-jest": "^23.0.0-alpha.0",
16+
"babel-plugin-transform-object-rest-spread": "^6.26.0",
17+
"babel-plugin-transform-runtime": "^6.23.0",
18+
"babel-preset-env": "^1.6.1",
19+
"jest": "^22.4.2",
20+
"jest-serializer-vue": "^1.0.0",
21+
"vue": "^2.5.16",
22+
"vue-jest": "^2.2.1",
23+
"vue-router": "^3.0.1",
24+
"vue-template-compiler": "^2.5.16",
25+
"vuex": "^3.0.1"
26+
},
27+
"jest": {
28+
"moduleDirectories": [
29+
"node_modules",
30+
"src"
31+
],
32+
"moduleFileExtensions": [
33+
"js",
34+
"vue"
35+
],
36+
"transform": {
37+
"^.+\\.js$": "<rootDir>/node_modules/babel-jest",
38+
".*\\.(vue)$": "<rootDir>/node_modules/vue-jest"
39+
},
40+
"snapshotSerializers": [
41+
"<rootDir>/node_modules/jest-serializer-vue"
42+
]
43+
}
44+
}

src/Simulate.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export default {
2+
click(elem) {
3+
if (elem) {
4+
elem.click()
5+
}
6+
}
7+
}

src/__mocks__/axios.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
get: jest.fn(() => Promise.resolve({data: {}})),
3+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Fetch makes an API call and displays the greeting when load-greeting is clicked 1`] = `
4+
<div>
5+
<button data-testid="load-greeting">
6+
Fetch
7+
</button> <span data-testid="greeting-text">hello there</span> {{ data ? : null}
8+
</div>
9+
`;

src/__tests__/components/Fetch.vue

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<template>
2+
<div>
3+
<button @click="fetch" data-testid="load-greeting">
4+
Fetch
5+
</button>
6+
<span v-if="data" data-testid="greeting-text">{{ data.greeting }}</span>
7+
{{ data ? : null}
8+
</div>
9+
</template>
10+
11+
<script>
12+
import axios from 'axios'
13+
14+
export default {
15+
props: {
16+
url: {
17+
type: String,
18+
required: true
19+
}
20+
},
21+
data () {
22+
return {
23+
data: null
24+
}
25+
},
26+
methods: {
27+
fetch () {
28+
axios
29+
.get(this.url)
30+
.then(response => this.data = response.data)
31+
}
32+
}
33+
}
34+
</script>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<template>
2+
<div>
3+
<span data-testid="number-display">{{ number }}</span>
4+
<span data-testid="instance-id">{{ id }}</span>
5+
</div>
6+
</template>
7+
8+
<script>
9+
let idCounter = 1
10+
11+
export default {
12+
props: {
13+
number: {
14+
type: Number,
15+
required: true
16+
}
17+
},
18+
data () {
19+
return {
20+
id: idCounter++
21+
}
22+
}
23+
}
24+
</script>

0 commit comments

Comments
 (0)