Skip to content

Instantly share code, notes, and snippets.

@wonderful-panda
Created December 16, 2016 03:42
Show Gist options
  • Save wonderful-panda/c6bf24e354d86e0d5fe1bfcb30bc876b to your computer and use it in GitHub Desktop.
Save wonderful-panda/c6bf24e354d86e0d5fe1bfcb30bc876b 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