jest-matcher-vue-test-utils v2.0.1
jest-matcher-vue-test-utils
Cute matchers for Jest to test Vue components with @vue/test-utils
.
Matchers
toRequireProp
// name-require-component.vue
props: {
name: {
type: String,
required: true
}
}
import Component from "./name-require-component.vue";
it("component requires name prop", () => {
expect(Component).toRequireProp("name"); // Passes
expect(Component).toRequireProp("birthday"); // Fails
});
Installation
Get from npm:
$ npm install -D jest-matcher-vue-test-utils
Then, register matchers on your jest process:
import vueTestUtilMatchers from "jest-matcher-vue-test-utils";
expect.extend({ ...vueTestUtilMatchers });
Config
We can configure the matchers. Currently accepting mountOptions property to give options for shallowMount
which is running in inside of matchers.
import vueTestUtilMatchers, { config } from "jest-matcher-vue-test-utils";
import { createLocalVue } from "@vue/test-utils";
config({
mountOptions: { localVue: createLocalVue() }
});
License
MIT, Copyright (c) 2018 Kengo Hamasaki
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago