Closed leodube-aot closed 10 months ago
@severinbeauvais @JazzarKarim @ketaki-deodhar I'm having an issue getting the unit tests to work for this component due to the DateMixin
mixin. I'm wondering if any of you have encountered anything similar with mixins in Vue 3 components.
The way original way we had it, which is the recommended way from vue-facing-decorator yields the following error in storybook:
this.yyyyMmDdToPacificDate is not a function
Changing it to mixins: [toNative(DateMixin)]
also doesn't work. The way I got it working in storybook for this PR is to extend the DateMixin, but the unit tests fail with a TypeError
.
Has anyone gotten unit tests to work for a component that uses a mixin yet? Been stuck on this for a little bit now and don't want to get too bogged down in it.
@severinbeauvais @JazzarKarim @ketaki-deodhar I'm having an issue getting the unit tests to work for this component due to the
DateMixin
mixin. I'm wondering if any of you have encountered anything similar with mixins in Vue 3 components.
Does it work if you import the "local" mixin instead of the shared one?
Does it work if you import the "local" mixin instead of the shared one?
No unfortunately it doesn't
Does it work if you import the "local" mixin instead of the shared one?
No unfortunately it doesn't
OK, that's partly good news. (It means the previous issue was resolved.)
What if you add the shared mixin to Storybook's (ie, this repo's) package file?
What if you add the shared mixin to Storybook's (ie, this repo's) package file?
It looks like the shared mixin is already a dependency of the base package.json
What if you add the shared mixin to Storybook's (ie, this repo's) package file?
It looks like the shared mixin is already a dependency of the base package.json
Oh yeah. So maybe it's a Storybook build/config issue? How does Storybook build this so that DatePicker can see the mixins?
@ketaki-deodhar , have you run across this yet?
What if you add the shared mixin to Storybook's (ie, this repo's) package file?
It looks like the shared mixin is already a dependency of the base package.json
Oh yeah. So maybe it's a Storybook build/config issue? How does Storybook build this so that DatePicker can see the mixins?
@ketaki-deodhar , have you run across this yet?
@severinbeauvais not really. Let me take a look
@severinbeauvais @JazzarKarim @ketaki-deodhar I'm having an issue getting the unit tests to work for this component due to the
DateMixin
mixin. I'm wondering if any of you have encountered anything similar with mixins in Vue 3 components.The way original way we had it, which is the recommended way from vue-facing-decorator yields the following error in storybook:
this.yyyyMmDdToPacificDate is not a function
Changing it to
mixins: [toNative(DateMixin)]
also doesn't work. The way I got it working in storybook for this PR is to extend the DateMixin, but the unit tests fail with aTypeError
.Has anyone gotten unit tests to work for a component that uses a mixin yet? Been stuck on this for a little bit now and don't want to get too bogged down in it.
can you try passing the mixin in the mount? Not sure if it will work or if right way to do it but something like below.....
can you try passing the mixin in the mount? Not sure if it will work or if right way to do it but something like below..... !
No luck unfortunately. I passed the mixin to the mount in the unit tests like so:
I ran it with the previous method of adding the mixin to the component, which doesn't seem to register the mixin based on the error message. In this case, both storybook and the unit tests fail.
I also tried running it with the way I extend the mixin in this PR. In this case storybook works but the unit tests fail.
I also tried running it with the way I extend the mixin in this PR. In this case storybook works but the unit tests fail.
OK, you got it down to a unit test error. That's progress. And if we decide to give up, we can forgo the unit tests for now (but we'd create a Tech Debt ticket to fix them later).
OK, you got it down to a unit test error. That's progress. And if we decide to give up, we can forgo the unit tests for now (but we'd create a Tech Debt ticket to fix them later).
It also fails before any of the tests are run (see the test summary copied below, I'm running the tests only for DatePicker.spec.ts so that's why there's only one test file). I imagine it might be some issue with the test setup that's thrown from the component. One thing I'm confused by is the mount
ing of the component only occurs within the tests themselves, but based on the output below none of them get a chance to run.
I'll keep working on it for another hour or so, and if I don't make any more progress I'll create a Tech Debt ticket to fix it later.
Test Files 1 failed (1)
Tests no tests
Start at 13:14:26
Duration 2.06s
Created new techdebt ticket for fixing up the unit tests. I'll get one more review before merging this PR.
can you try passing the mixin in the mount? Not sure if it will work or if right way to do it but something like below..... !
No luck unfortunately. I passed the mixin to the mount in the unit tests like so:
I ran it with the previous method of adding the mixin to the component, which doesn't seem to register the mixin based on the error message. In this case, both storybook and the unit tests fail.
I also tried running it with the way I extend the mixin in this PR. In this case storybook works but the unit tests fail.
Unit tests are a big pain point :(
Unit tests are a big pain point :(
I agree haha I felt like I was going in circles yesterday
Issue #: /bcgov/entity#18779
Description of changes:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the business-filings-ui license (Apache 2.0).