Skip to content

Instantly share code, notes, and snippets.

@suplo
Forked from wonderful-panda/example.ts
Created June 5, 2017 06:30
Show Gist options
  • Save suplo/2d9aac87c5e604e89c39e3e3b801dbbe to your computer and use it in GitHub Desktop.
Save suplo/2d9aac87c5e604e89c39e3e3b801dbbe to your computer and use it in GitHub Desktop.
Asynchronous test of vue with mocha
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