-
Notifications
You must be signed in to change notification settings - Fork 668
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
Unit testing nested components - Child's emitted
is undefined
#819
Comments
The event does seem to be triggered - however it is not added to the array returned by A long time ago, before let eventName: string = ''
let payload: Array = []
function createEventRecorder() {
return (event: string, ...args: any[]): Vue =>
{
eventName = event
payload = args
return new Vue();
};
} expect(eventName)...
expect(payload)... And mocking out the @eddyerburgh does this seem like a bug? If so, I can help isolate it with you. I made a PR against the |
Yes this is a bug. I believe the bug is because the child component is extended from Vue before the event logging mixin is added. @lmiller1990 it would be great if you could pick this up. |
Ok thanks. Excited to work on this over the weekend. I need this in my app, too. |
I thought it was related to the mixin timing too... but maybe not. I created a test using the It fails in the reproduction repo, though, as you can see here. So far only using Will keep investigating. |
The issue is that the sub component created with Vue.extend doesn't have the logEvents mixin applied. I'll fix this |
Ok, great. I'll review the PR, I would like to see how you fix this. |
Version
1.0.0-beta.20
Reproduction link
https://github.com/bugsduggan/vue-test-utils-bug
Steps to reproduce
Clone the repo and run
npm run test:unit
. There will be one failing test indicating that theChildComponent
's emitted is undefined.What is expected?
Having used
mount
instead ofshallowMount
, I was hoping to be able to see events that have been emitted by theChildComponent
.What is actually happening?
ChildComponent
'semitted
function returns undefined.I appreciate that this could be seen as testing the implementation of vue but I have 2 components that are very tightly coupled in my application and it is important for us to be able to check what events are being triggered by the child component while unit testing the parent.
If someone can help me narrow down the causes of this bug (and if it's not impossible or undesirable to fix), I would be happy to devote some hours into a pull request.
The text was updated successfully, but these errors were encountered: