-
-
Save suplo/2d9aac87c5e604e89c39e3e3b801dbbe to your computer and use it in GitHub Desktop.
Asynchronous test of vue with mocha
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as Vue from "vue"; | |
import * as assert from "power-assert"; | |
function nextTick() { | |
return new Promise((resolve, _) => Vue.nextTick(resolve)); | |
} | |
describe("vue component tests", function() { | |
it("works properly", async function() { // don't use `done` with async function | |
const vm = new Vue({ ... }); | |
assert(vm.$el.innerHTML === "..."); | |
vm.$emit("someEvent", { ... }); | |
await nextTick(); | |
assert(vm.$el.innerHTML === "..."); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment