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
spyOnEvent has wrong event.detail data if a custom event emits a Map or a dom element. #1841
Comments
it's not trivial to move complex objects from browser to node, notice that the tests ar running in node, but your app is running in the browser using puppeteer. |
@manucorporat That's fair. I've been able to achieve some goals relying on |
Maybe spyOnEvent could be amended to accept a callback function that uses page.evaluate under the hood? That way a user can perform operations on an object in the page scope, then pass that back to node for assertion. |
I am also encountering this issue. I agree that it would be nice to at least document this behavior. FWIW, I am seeing the value |
me too. I use
@pr3tori4n Can I get sample code if you have a solution? |
This bug seems to be affecting me as well, but in a different way. I have a component that emits a custom event, let's call it this.tabAcitived.emit({ index, tab}); My test is like so: //...
const tabs = await page.find('tab-bar');
const activatedEvent = await tabs.spyOnEvent('tabActivated');
await tabs.callMethod('activateTab', 0);
await page.waitForChanges();
expect(activatedEvent).toHaveReceivedEventTimes(1); My test will fail, saying the event was never received. Removing the DOM element from the event details allows the tests to pass. |
Stencil version:
I'm submitting a:
[x] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://stencil-worldwide.herokuapp.com/ or https://forum.ionicframework.com/
Current behavior:
when using
page.spyOnEvent()
to spy on a custom stencil emitted event, if data was passed from the event, the spy'sevent.detail
is incorrect.Expected behavior:
When validating the event.detail from the spys event object, the data should match what the component passes.
Steps to reproduce:
e2eElement.spyOnEvent()
toHaveReceivedEventDetail
.Related code:
Other information:
stencil/src/testing/puppeteer/puppeteer-declarations.ts
Line 105 in c6bd82d
The text was updated successfully, but these errors were encountered: