You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched for existing issues that already report this problem, without success.
Stencil Version
4.7.0
Current Behavior
Hi, I have a little component that listents to an event:
@Component({tag: 'e2e-events-ticket'})exportclassE2eEventsTicket{handleFileUploaded(event:CustomEvent):void{console.log('[COMPONENT] is file array fn exists',!!event.detail.arrayBuffer);}render(){return(<Host><file-uploadonFileUploaded={event=>this.handleFileUploaded(event)}/></Host>);}}
file-upload is a component that contains a <input type=file/> and follows the event when a user chooses a file. In runtime, it works like a charm, but I can't test it:
describe('e2e-events-ticket',()=>{it('should work',async()=>{constpage=awaitnewE2EPage();awaitpage.setContent('<e2e-events-ticket></e2e-events-ticket>');constfileImportComponent=awaitpage.find('e2e-events-ticket').then(el=>el.find('file-upload'));expect(fileImportComponent).toBeTruthy();constmockFile={arrayBuffer: ()=>Promise.resolve(newUint32Array([1,2])asArrayBuffer),name: 'filename'};console.log('[TEST] is file array fn exists',!!mockFile.arrayBuffer);fileImportComponent.triggerEvent('fileUploaded',{detail: mockFile});awaitpage.waitForChanges();});});
I trigger an event whose detail is an object {name: string; arrayBuffer: () => Promise<ArrayBuffer>} ; but on my component side, I only receive {name: string;}, as if the details object methods are omitted!
Here's the logs:
● Console
console.log
[TEST] is file array fn exists true
at Object.<anonymous> (src/components/e2e-events-ticket/e2e-events-ticket.e2e.ts:23:13)
console.log
[COMPONENT] is file array fn exists false
Location: http://localhost:3345/build/e2e-events-ticket.entry.js:7:16
at t (node_modules/@stencil/core/testing/index.js:15048:67)
at Array.map (<anonymous>)
at Array.map (<anonymous>)
I looked into you provided example and was able to reproduce it. It seems that the object passed into the components event listener (handleFileUploaded) is a JSHandle and not the serialized object. I recommend to try initialize the CustomEvent on the browser side within an evaluate callback. I will ingest this into our backlog to evaluate how we can improve this interface to either forbid complex types such as array buffer or enhance the functionality to support these use cases.
Prerequisites
Stencil Version
4.7.0
Current Behavior
Hi, I have a little component that listents to an event:
file-upload
is a component that contains a<input type=file/>
and follows the event when a user chooses a file. In runtime, it works like a charm, but I can't test it:I trigger an event whose detail is an object
{name: string; arrayBuffer: () => Promise<ArrayBuffer>}
; but on my component side, I only receive{name: string;}
, as if the details object methods are omitted!Here's the logs:
Expected Behavior
The details object to contain the defined methods
System Info
Steps to Reproduce
npm i && npm run test-e2e-event
Code Reproduction URL
https://github.com/candiotti-ca/create-stencil
Additional Information
No response
The text was updated successfully, but these errors were encountered: