Registry / testing / jest-matcher-vue-test-utils

jest-matcher-vue-test-utils

JSON →
library2.0.1jsnpmunverified

Custom Jest matchers for testing Vue components with @vue/test-utils (v1.x). Current version 2.0.1 supports Vue 2. Provides expressive matchers like toBeAScopedSlot, toBeADisabledButton, and toHaveBeenEmitted for common UI assertions. Less actively maintained since Vue 3 adoption; peer dependency on @vue/test-utils ^1.0.0-beta.20 and Jest >=23.0. Limited to Vue 2 projects.

npm install jest-matcher-vue-test-utils
INSTALL
IMPORT
SIG · JEST-MATCHER-VUE-T
J
jest-matcher-vue-test-utils
testingjavascriptv2.0.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

toBeAScopedSlot
import { toBeAScopedSlot } from 'jest-matcher-vue-test-utils'
const { toBeAScopedSlot } = require('jest-matcher-vue-test-utils');
ESM import; require works but not recommended; types included
default matchers (all)
import 'jest-matcher-vue-test-utils';
import * as matchers from 'jest-matcher-vue-test-utils';
Register all matchers via side-effect import; do not name import
custom matcher types
import type { CustomMatcher } from 'jest-matcher-vue-test-utils';
TypeScript users: import types for custom matchers if needed

Shows how to extend Jest with a single matcher and use it on a Vue wrapper element.

import { shallowMount } from '@vue/test-utils'; import { toBeADisabledButton } from 'jest-matcher-vue-test-utils'; expect.extend({ toBeADisabledButton }); const wrapper = shallowMount({ template: '<button disabled>Click me</button>' }); test('button is disabled', () => { expect(wrapper.find('button')).toBeADisabledButton(); });
Debug
Known issues
breakingVersion 2.x requires @vue/test-utils ^1.0.0-beta.20; not compatible with Vue Test Utils 2.x (Vue 3).
fix
For Vue 3, use '@testing-library/vue' or custom matchers; this library is Vue 2 only.
affects: >=2.0.0
deprecatedMatchers like toBeAScopedSlot and toHaveBeenEmitted are deprecated in favor of Vue Test Utils native APIs.
fix
Use wrapper.find(...).attributes() or wrapper.emitted() directly.
affects: >=2.0.0
gotchaMatchers must be registered individually or via side-effect import; globals are not set automatically.
fix
Call expect.extend({ ... }) or import 'jest-matcher-vue-test-utils' in setup file.
affects: >=1.0.0
breakingVersion 1.x used a different export pattern; imports may break when upgrading from 1.x to 2.x.
fix
Update import paths: from 'jest-matcher-vue-test-utils/extend' to direct imports.
affects: >=2.0.0
Errors
Common errors & fixes
expect(...).toBeADisabledButton is not a function
Matcher not registered via expect.extend or side-effect import.
fix
Add import 'jest-matcher-vue-test-utils' or expect.extend({ toBeADisabledButton }) in your test setup.
Cannot find module '@vue/test-utils' from 'jest-matcher-vue-test-utils'
Missing peer dependency @vue/test-utils.
fix
Run npm install --save-dev @vue/test-utils@^1.0.0-beta.20
TypeError: vue_template_compile is not a function
Using Vue 3 with @vue/test-utils v2; library only supports Vue 2.
fix
Downgrade to Vue 2 and @vue/test-utils v1, or use a different testing library.
Upgrade
Version history
2.0.1latest on npm
Audit
Dependencies
@vue/test-utilsrequiredpeer dependency for Vue component testing
jestrequiredpeer dependency for Jest matchers
Agent activity
9 hits · last 30 days
node
8
Resources
jest-matcher-vue-test-utils — npm install jest-matcher-vue-test-utils · libregistry