This week has been an interesting week as it was mostly debugging and fixing tests.

Our rails project runs on Rails 4.2 and we are now working n moving to Rails 5 on the sideline.

We use Jasmine tests for our Javascript code. We heavily utilise CkEditor as an UI interface to insert dynamic HTML content. However with Rails 5 we noticed that Jasmine tests are started to fail CkEditor test specs.

It was not obvious at first. However I was debugging the code and realize that we don’t properly destroy the CkEditor instance upon test completion.

As a result old CkEditor instances are still executed after we have cleared the DOM. Therefore we had to change the Jasmine tests to make sure the instance is properly destroyed.

The buggy behavior was in the code, we simply exit the destroy method if the CkEditor instance is not created. However because of that the CkEditor instance will still get created asynchronously.

To resolve it, in the destroy method, I wait until the CkEditor instance is ready, and then callĀ  destroy the instance.

Published by Sinaru Gunawardena

Sinaru is a software developer at work and a painter in free time. He enjoys writing tech notes on his personal website. He currently lives in Dublin, Ireland.

Leave a comment

Your email address will not be published. Required fields are marked *