Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vue-test-utils-compat

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-test-utils-compat - npm Package Compare versions

Comparing version 0.0.11 to 0.0.12

tests/flags/wrapper/wrapper-attributes-from-attrs.test.js

6

CHANGELOG.md

@@ -0,1 +1,7 @@

# 0.0.12
- Added flags:
- WRAPPER_UNWRAP_EMITTED
- WRAPPER_ATTRIBUTES_FROM_ATTRS
# 0.0.11

@@ -2,0 +8,0 @@

36

dist/vue-test-utils-compat.cjs.js

@@ -20,2 +20,11 @@ 'use strict';

if (attr) {
if (
compatConfig.WRAPPER_ATTRIBUTES_FROM_ATTRS &&
originalAttributes == null &&
wrapper.vm?.$attrs &&
attr in wrapper.vm.$attrs
) {
return wrapper.vm.$attrs[attr];
}
return originalAttributes;

@@ -411,2 +420,3 @@ }

WRAPPER_ATTRIBUTES_VALUE: "WRAPPER_ATTRIBUTES_VALUE",
WRAPPER_ATTRIBUTES_FROM_ATTRS: "WRAPPER_ATTRIBUTES_FROM_ATTRS",
WRAPPER_UNWRAP_PROPS: "WRAPPER_UNWRAP_PROPS",

@@ -416,2 +426,3 @@ WRAPPER_DESTROY: "WRAPPER_DESTROY",

WRAPPER_DO_NOT_INCLUDE_HOOK_EVENTS_IN_EMITTED: "WRAPPER_DO_NOT_INCLUDE_HOOK_EVENTS_IN_EMITTED",
WRAPPER_UNWRAP_EMITTED: "WRAPPER_UNWRAP_EMITTED",
WRAPPER_FIND_ALL: "WRAPPER_FIND_ALL",

@@ -551,3 +562,3 @@ WRAPPER_FIND_BY_CSS_SELECTOR_RETURNS_COMPONENTS: "WRAPPER_FIND_BY_CSS_SELECTOR_RETURNS_COMPONENTS",

if (compatConfig.WRAPPER_DO_NOT_INCLUDE_HOOK_EVENTS_IN_EMITTED) {
if (compatConfig.WRAPPER_DO_NOT_INCLUDE_HOOK_EVENTS_IN_EMITTED || compatConfig.WRAPPER_UNWRAP_EMITTED) {
VTU.config.plugins.VueWrapper.install((wrapper) => {

@@ -557,4 +568,9 @@ const { emitted } = wrapper;

emitted(event) {
// eslint-disable-next-line no-underscore-dangle
const unwrapEmittedEntry = (entry) => entry.map((obj) => obj?.__v_raw ?? obj);
const result = emitted.call(this, event);
if (arguments.length === 1) {
if (compatConfig.WRAPPER_UNWRAP_EMITTED) {
return result?.map(unwrapEmittedEntry);
}
return result;

@@ -564,6 +580,14 @@ }

Object.keys(result).forEach((k) => {
if (k.startsWith("hook:")) {
delete result[k];
if (compatConfig.WRAPPER_DO_NOT_INCLUDE_HOOK_EVENTS_IN_EMITTED) {
if (k.startsWith("hook:")) {
delete result[k];
return;
}
}
if (compatConfig.WRAPPER_UNWRAP_EMITTED) {
result[k] = result[k]?.map(unwrapEmittedEntry);
}
});
return result;

@@ -599,3 +623,7 @@ },

if (compatConfig.WRAPPER_ATTRIBUTES_VALUE || compatConfig.WRAPPER_ATTRIBUTES_DISABLED) {
if (
compatConfig.WRAPPER_ATTRIBUTES_VALUE ||
compatConfig.WRAPPER_ATTRIBUTES_DISABLED ||
compatConfig.WRAPPER_ATTRIBUTES_FROM_ATTRS
) {
install$3(VTU, compatConfig);

@@ -602,0 +630,0 @@ }

@@ -18,2 +18,11 @@ function install$3(VTU, compatConfig) {

if (attr) {
if (
compatConfig.WRAPPER_ATTRIBUTES_FROM_ATTRS &&
originalAttributes == null &&
wrapper.vm?.$attrs &&
attr in wrapper.vm.$attrs
) {
return wrapper.vm.$attrs[attr];
}
return originalAttributes;

@@ -409,2 +418,3 @@ }

WRAPPER_ATTRIBUTES_VALUE: "WRAPPER_ATTRIBUTES_VALUE",
WRAPPER_ATTRIBUTES_FROM_ATTRS: "WRAPPER_ATTRIBUTES_FROM_ATTRS",
WRAPPER_UNWRAP_PROPS: "WRAPPER_UNWRAP_PROPS",

@@ -414,2 +424,3 @@ WRAPPER_DESTROY: "WRAPPER_DESTROY",

WRAPPER_DO_NOT_INCLUDE_HOOK_EVENTS_IN_EMITTED: "WRAPPER_DO_NOT_INCLUDE_HOOK_EVENTS_IN_EMITTED",
WRAPPER_UNWRAP_EMITTED: "WRAPPER_UNWRAP_EMITTED",
WRAPPER_FIND_ALL: "WRAPPER_FIND_ALL",

@@ -549,3 +560,3 @@ WRAPPER_FIND_BY_CSS_SELECTOR_RETURNS_COMPONENTS: "WRAPPER_FIND_BY_CSS_SELECTOR_RETURNS_COMPONENTS",

if (compatConfig.WRAPPER_DO_NOT_INCLUDE_HOOK_EVENTS_IN_EMITTED) {
if (compatConfig.WRAPPER_DO_NOT_INCLUDE_HOOK_EVENTS_IN_EMITTED || compatConfig.WRAPPER_UNWRAP_EMITTED) {
VTU.config.plugins.VueWrapper.install((wrapper) => {

@@ -555,4 +566,9 @@ const { emitted } = wrapper;

emitted(event) {
// eslint-disable-next-line no-underscore-dangle
const unwrapEmittedEntry = (entry) => entry.map((obj) => obj?.__v_raw ?? obj);
const result = emitted.call(this, event);
if (arguments.length === 1) {
if (compatConfig.WRAPPER_UNWRAP_EMITTED) {
return result?.map(unwrapEmittedEntry);
}
return result;

@@ -562,6 +578,14 @@ }

Object.keys(result).forEach((k) => {
if (k.startsWith("hook:")) {
delete result[k];
if (compatConfig.WRAPPER_DO_NOT_INCLUDE_HOOK_EVENTS_IN_EMITTED) {
if (k.startsWith("hook:")) {
delete result[k];
return;
}
}
if (compatConfig.WRAPPER_UNWRAP_EMITTED) {
result[k] = result[k]?.map(unwrapEmittedEntry);
}
});
return result;

@@ -597,3 +621,7 @@ },

if (compatConfig.WRAPPER_ATTRIBUTES_VALUE || compatConfig.WRAPPER_ATTRIBUTES_DISABLED) {
if (
compatConfig.WRAPPER_ATTRIBUTES_VALUE ||
compatConfig.WRAPPER_ATTRIBUTES_DISABLED ||
compatConfig.WRAPPER_ATTRIBUTES_FROM_ATTRS
) {
install$3(VTU, compatConfig);

@@ -600,0 +628,0 @@ }

2

package.json
{
"name": "vue-test-utils-compat",
"version": "0.0.11",
"version": "0.0.12",
"description": "Compat layer for @vue/test-utils@2.x",

@@ -5,0 +5,0 @@ "main": "dist/vue-test-utils-compat.cjs.js",

@@ -22,2 +22,3 @@ # vue-test-utils-compat [![npm badge](https://img.shields.io/npm/v/vue-test-utils-compat)](https://npmjs.com/vue-test-utils-compat)

- [EXPORT_CREATE_WRAPPER](#export_create_wrapper)
- [EXPORT_ERROR_WRAPPER](#export_error_wrapper-added-in-v0011)
- [MOUNT_ARGS_COMPONENTS](#mount_args_components-added-in-v003)

@@ -34,2 +35,5 @@ - [MOUNT_ARGS_CONTEXT\_\*](#mount_args_context_)

- [WRAPPER_ATTRIBUTES_VALUE](#wrapper_attributes_value)
- [WRAPPER_ATTRIBUTES_FROM_ATTRS](#wrapper_attributes_from_attrs-added-in-v0012)
- [WRAPPER_UNWRAP_PROPS](#wrapper_unwrap_props-added-in-v0011)
- [WRAPPER_UNWRAP_EMITTED](#wrapper_unwrap_emitted-added-in-v0012)
- [WRAPPER_DESTROY](#wrapper_destroy)

@@ -270,2 +274,8 @@ - [WRAPPER_DO_NOT_INCLUDE_NATIVE_EVENTS_IN_EMITTED](#wrapper_do_not_include_native_events_in_emitted)

### WRAPPER_ATTRIBUTES_FROM_ATTRS (added in v0.0.12)
Add `$attrs` lookup when looking for `.attributes('something')` call. Previously test-utils were looking into $attrs, now only attributes of root element are considered
➡️ Migration strategy: ❌ rewrite your value retrieval in another way
### WRAPPER_UNWRAP_PROPS (added in v0.0.11)

@@ -277,2 +287,8 @@

### WRAPPER_UNWRAP_EMITTED (added in v0.0.12)
Unwraps emitted objects to allow strict checks like `.toBe` pass
➡️ Migration strategy: when asserting emitted() of the component use relaxed check (like `.toStrictEqual`) instead strict `===` equality
### WRAPPER_DESTROY

@@ -279,0 +295,0 @@

@@ -18,2 +18,11 @@ export function install(VTU, compatConfig) {

if (attr) {
if (
compatConfig.WRAPPER_ATTRIBUTES_FROM_ATTRS &&
originalAttributes == null &&
wrapper.vm?.$attrs &&
attr in wrapper.vm.$attrs
) {
return wrapper.vm.$attrs[attr];
}
return originalAttributes;

@@ -20,0 +29,0 @@ }

@@ -40,2 +40,3 @@ import { install as installWrapperAttributesCompat } from "./compats/wrapper-attributes.js";

WRAPPER_ATTRIBUTES_VALUE: "WRAPPER_ATTRIBUTES_VALUE",
WRAPPER_ATTRIBUTES_FROM_ATTRS: "WRAPPER_ATTRIBUTES_FROM_ATTRS",
WRAPPER_UNWRAP_PROPS: "WRAPPER_UNWRAP_PROPS",

@@ -45,2 +46,3 @@ WRAPPER_DESTROY: "WRAPPER_DESTROY",

WRAPPER_DO_NOT_INCLUDE_HOOK_EVENTS_IN_EMITTED: "WRAPPER_DO_NOT_INCLUDE_HOOK_EVENTS_IN_EMITTED",
WRAPPER_UNWRAP_EMITTED: "WRAPPER_UNWRAP_EMITTED",
WRAPPER_FIND_ALL: "WRAPPER_FIND_ALL",

@@ -180,3 +182,3 @@ WRAPPER_FIND_BY_CSS_SELECTOR_RETURNS_COMPONENTS: "WRAPPER_FIND_BY_CSS_SELECTOR_RETURNS_COMPONENTS",

if (compatConfig.WRAPPER_DO_NOT_INCLUDE_HOOK_EVENTS_IN_EMITTED) {
if (compatConfig.WRAPPER_DO_NOT_INCLUDE_HOOK_EVENTS_IN_EMITTED || compatConfig.WRAPPER_UNWRAP_EMITTED) {
VTU.config.plugins.VueWrapper.install((wrapper) => {

@@ -186,4 +188,9 @@ const { emitted } = wrapper;

emitted(event) {
// eslint-disable-next-line no-underscore-dangle
const unwrapEmittedEntry = (entry) => entry.map((obj) => obj?.__v_raw ?? obj);
const result = emitted.call(this, event);
if (arguments.length === 1) {
if (compatConfig.WRAPPER_UNWRAP_EMITTED) {
return result?.map(unwrapEmittedEntry);
}
return result;

@@ -193,6 +200,14 @@ }

Object.keys(result).forEach((k) => {
if (k.startsWith("hook:")) {
delete result[k];
if (compatConfig.WRAPPER_DO_NOT_INCLUDE_HOOK_EVENTS_IN_EMITTED) {
if (k.startsWith("hook:")) {
delete result[k];
return;
}
}
if (compatConfig.WRAPPER_UNWRAP_EMITTED) {
result[k] = result[k]?.map(unwrapEmittedEntry);
}
});
return result;

@@ -228,3 +243,7 @@ },

if (compatConfig.WRAPPER_ATTRIBUTES_VALUE || compatConfig.WRAPPER_ATTRIBUTES_DISABLED) {
if (
compatConfig.WRAPPER_ATTRIBUTES_VALUE ||
compatConfig.WRAPPER_ATTRIBUTES_DISABLED ||
compatConfig.WRAPPER_ATTRIBUTES_FROM_ATTRS
) {
installWrapperAttributesCompat(VTU, compatConfig);

@@ -231,0 +250,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc