test(e2e): add e2e test for commits example (#526)

* test(e2e): add e2e test for commits example

* test(e2e): add waitForResponse to enhance the test

* test(e2e): use mocks for commits test
This commit is contained in:
CodinCat
2019-12-11 23:51:15 +09:00
committed by Evan You
parent 2a994094de
commit f48a4f71a7
4 changed files with 639 additions and 9 deletions

View File

@@ -1,4 +1,5 @@
<script src="../../dist/vue.global.js"></script>
<script src="../mocks/commits.js"></script>
<div id="demo">
<h1>Latest Vue.js Commits</h1>
@@ -41,11 +42,18 @@ const App = {
methods: {
fetchData() {
fetch(`${API_URL}${this.currentBranch}`)
.then(res => res.json())
.then(data => {
this.commits = data
})
if (window.location.hash === '#test') {
// use mocks in e2e to avoid dependency on network / authentication
setTimeout(() => {
this.commits = window.MOCKS[this.currentBranch]
}, 0)
} else {
fetch(`${API_URL}${this.currentBranch}`)
.then(res => res.json())
.then(data => {
this.commits = data
})
}
},
truncate(v) {
const newline = v.indexOf('\n')