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
functioncreateHtmlImg(src: File): HTMLImageElement{constimg=newImage();img.crossOrigin='anonymous';img.src=URL.createObjectURL(src);returnimg;}```The test throwing the error looks like this: ```tsit('should emit ready event when image is loaded',()=>{global.Image=jest.fn().mockImplementation(()=>({onerror: jest.fn(),src: '',setonload(value: ()=>void){value();},}));letready;spectator.output('ready').subscribe((output)=>(ready=output));spectator.setInput('image',newFile(['data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAIAQMAAAD+wSzIAAAABlBMVEX///+/v7+jQ3Y5AAAADklEQVQI12P4AIX8EAgALgAD/aNpbtEAAAAASUVORK5CYII',],'filename.png',{type: 'image/png'},),);expect(ready).not.toBe(undefined);});
Does someone know, why the issue below happens?
Please provide a link to a minimal reproduction of the bug
No response
Please provide the exception or error you saw
ERROR RuntimeError: NG0600: Writing to signals is not allowed in a `computed` or an `effect` by default. Use `allowSignalWrites` in the `CreateEffectOptions` to enable this inside effects.
at /Users/nicolaric/projects/akenza-ui/node_modules/@angular/core/fesm2022/core.mjs:31219:15
Please provide the environment you discovered this bug in (run ng version)
Angular 17.3.5
Anything else?
No response
The text was updated successfully, but these errors were encountered:
it works when not running in the test. it fails when running the test.
This is because your test resolves the image loading synchronously which means that your onload event handler runs as part of the effect defined in the constructor. In this sense your test and production code behave differently.
You've got several options to address the warning:
make the test asynchronous;
add the allowSignalWrites option;
Idle though - it would help debugging those scenarios if we could easily / quickly identify an effect that triggers a warning.
Which @angular/* package(s) are the source of the bug?
core
Is this a regression?
Yes
Description
Hey y'all
I am currently trying to run tests against my image crop component. There, I have the following method:
the
createHtmlImg
function looks like this:Does someone know, why the issue below happens?
Please provide a link to a minimal reproduction of the bug
No response
Please provide the exception or error you saw
Please provide the environment you discovered this bug in (run
ng version
)Anything else?
No response
The text was updated successfully, but these errors were encountered: