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>
|
||||
@@ -37,10 +38,17 @@ const App = {
|
||||
const currentBranch = ref('master')
|
||||
const commits = ref(null)
|
||||
|
||||
watch(() => {
|
||||
fetch(`${API_URL}${currentBranch.value}`)
|
||||
.then(res => res.json())
|
||||
.then(data => { commits.value = data })
|
||||
watch([currentBranch, commits], () => {
|
||||
if (window.location.hash === '#test') {
|
||||
// use mocks in e2e to avoid dependency on network / authentication
|
||||
setTimeout(() => {
|
||||
commits.value = window.MOCKS[currentBranch.value]
|
||||
}, 0)
|
||||
} else {
|
||||
fetch(`${API_URL}${currentBranch.value}`)
|
||||
.then(res => res.json())
|
||||
.then(data => { commits.value = data })
|
||||
}
|
||||
})
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user