ckeditor5-angular
ckeditor5-angular copied to clipboard
Problem with testing the component with jest
Hey there!
We're using this package in combination with jest as our testing framework. Because jest and ts-jest can't yet handle es modules, it is not possible to run unit tests. The only reason for that is the included CKEditor watchdog, which we don't actually need. Is there a way to remove this dependency and make it optional?
I was not able to find an easy way to set up ts-jest in a way that allows using es modules, and I'd like to avoid pulling in babel just for those few tests.
cc @ma2ciek
Hi!
I'm aware that currently, it's not possible to make it an optional dependency. The Watchdog feature was built-in into the component so it can restart the editor inside the component, which can't be done from the outside.
We'll try to merge the Watchdog to the ckeditor5-angular
bundle in the future since this external import causes some problems from time to time.
An external import would make sense here but we chose the direct import from the ckeditor5-angular
package as we weren't aware of such problems :/
I'm marking it as a bug, though, ideally, it could be fixed on the jest's side.
any update on it?
Any updates on this issue?
Hey, are there any plans on fixing this issue? We wanted to integrate your editor into our application, but sadly our tests fail because of this watchdog part. It would be really nice if this would get fixed, in the near future 😃
So for anyone interested in testing CKEditor 5 in Jest – you should be able to configure Jest to transpile CKEditor 5 from node_modules
dir and stub its SVG and CSS files. I've posted this on SO as well.
But this is if you really need to load the whole editor into the test, which might be not so optimal. The other solution would be to use Jest's module mapper to entirely mock the CKEditor inside UI tests.