Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

render objects #17

Open
dcrystalj opened this issue Jun 3, 2019 · 3 comments
Open

render objects #17

dcrystalj opened this issue Jun 3, 2019 · 3 comments

Comments

@dcrystalj
Copy link

dcrystalj commented Jun 3, 2019

problem

passing object to prop of one component should be serialized

example

serializing following component:

<template>
<div>
 <custom-component :data="{a: true}">
</div>
</template>

gives you somehting like this:

exports[`InstantOrderForm snapshot renders 1`] = `
<div>
 <custom-component-stub data="[object Object]">
</div>

solution

can this be fixed? am I doing something wrong?
I would like to keep data="{a: true}" in snapshot

@TheJaredWilcurt
Copy link
Contributor

TheJaredWilcurt commented Jan 16, 2020

@dcrystalj This was a great request. It was also a huge pain in the ass to get to work. But here I am, 1am publishing to npm.

// this will work
expect(wrapper)
  .toMatchSnapShot();

// this will not, the `[object Object]` is already in place
expect(wrapper.html())
  .toMatchSnapshot();

The feature is experimental, so create issues if you have problems with it. You will need to enable it in your vue.config.js file.

module.exports = {
  pluginOptions: {
    jestSerializer: {
      stringifyObjects: true
    }
  }
};

@edfowle
Copy link

edfowle commented Oct 11, 2021

+1 for this feature request, are there any plans to merge in @TheJaredWilcurt's work?

@eddyerburgh
Copy link
Owner

I'm quite busy at the moment (my first son was born a few months ago) but I'm happy to review and merge PRs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants