vuejs / vue-jest

Jest Vue transformer
MIT License
748 stars 156 forks source link

feat: enable sugar ref take 2 for vue3-jest #377

Closed cexbrayat closed 3 years ago

cexbrayat commented 3 years ago

This PR allows testing components using sugar ref take 2 https://github.com/vuejs/rfcs/discussions/369

Note that I did not make it configurable for now, but maybe it should be. Opinions?

lmiller1990 commented 3 years ago

Nice. What do you mean by configurable? If you aren't using the ref sugar, you won't be impacted by this update, right?

cexbrayat commented 3 years ago

I think you won't be impacted (we could merge and release an alpha to make sure of it on our projects).

The probable edge case is someone naming its own variables $ref or another reserved sugar syntax... In that case, vue-jest will transform them and probably error, whereas vue-next will not unless explicitly told? I'm not 100% sure, as I'm not using sugar ref in my own projects.

lmiller1990 commented 3 years ago

It seems really unlikely someone named their variable $ref, so I think this is fine.

sibbng commented 3 years ago

Ref take 2 also includes helpers like $() and $$() which can be conflict with https://github.com/antfu/v-dollar or any function named as or aliased to $ like:

import { unref as $ } from 'vue'

I don't think people do that more often than using new ref syntax with script setup, but it would be weird to make people disable new ref transform on jest config whilst they didn't enable it on their app.