codedbychavez / configcat-vue

Vue.js SDK for ConfigCat Feature Flags (community maintained)
https://configcat.com/docs/sdk-reference/community/vue/
3 stars 1 forks source link

How to use with a test suite? #16

Closed bmulholland closed 7 months ago

bmulholland commented 9 months ago

We need to write unit & e2e tests that cover both states of the feature flipper. How do we do that? Can we just follow these instructions and the overrides will apply to the Vue component's state? Is there another way to force the value to be something? Would need to be at runtime, e.g. in the browser, I think.

adams85 commented 9 months ago

Can we just follow these instructions and the overrides will apply to the Vue component's state?

Yep, I think this is the simplest approach. Flag overrides should work with the Vue plugin just fine.

Is there another way to force the value to be something?

Alternatively, providing a mock for IConfigCatClient could work as well, since it's injected as a dependency. You'd need to provide some fake implementation of IConfigCatClient.snaphot(), plus of IConfigCatClient.on("configChanged", ...) if you want to test state transitions.

adams85 commented 7 months ago

FYI, we've added a few tests recently, so now we have some examples of how to apply those mocking techniques I talked about in my previous comment: https://github.com/codedbychavez/configcat-vue/blob/main/tests/unit/FeatureWrapper.spec.ts

codedbychavez commented 7 months ago

Closing...