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:
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user