This repo reproduces an event issue.
npm install
npm startThe <my-parent> component:
- adds an event listener for "my-event" in the
constructor - renders the component
<my-child>in its JSX template
The <my-child> component:
- dispatches a "my-event" event in the
componentDidLoadlifecycle method
<my-parent>should receive the "my-event" event from <my-child>. This works as expected in the browser, but not in the SPEC test.
To demonstrate this, 3 messages are logged to the console:
- "adding event listener" by
<my-parent> - "dispatching event" by
<my-child> - "event received" by
<my-parent>
In the browser, all three messages are logged. In "my-parent.spec.ts" only the first two messages are logged. The event handler is not being called.