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

feat: expose everything on wrapper.vm to help testing script setup #931

Merged
merged 1 commit into from
Sep 24, 2021

Commits on Sep 9, 2021

  1. feat: expose everything on wrapper.vm

    This commit changes `wrapper.vm` to actually point to `vm.$.proxy`.
    This shouldn't change the behaviour of existing tests, but allows components written with `script setup` to be tested as well,
    without the need to expose everything just for testing purposes.
    
    For example a component like:
    
    ```vue
    <script setup lang="ts">
    import { ref } from 'vue'
    
    const count = ref(0)
    </script>
    ```
    
    can now be tested like `expect(wrapper.vm.count).toBe(0)`, whereas you previously had to add `defineExpose({ count })` for this to work.
    
    The downside is that you now can't test that something is _not_ exposed by a component, but I don't think this is a problem.
    
    This also removes the previous hacks for script setup, as it looks like they are no longer necessary.
    cexbrayat committed Sep 9, 2021
    Configuration menu
    Copy the full SHA
    25dfe7f View commit details
    Browse the repository at this point in the history