Adding client-side QUnit test cases
Building new fields or views is very simple in Odoo. In just a few lines of XML, you can define a new view. However, under the hood, it uses a lot of JavaScript. Modifying/adding new features on the client side is complex, and it might break a few things. Most client-side issues go unnoticed, as most errors are only displayed in the console. So, QUnit test cases are used in Odoo to check the correctness of different JavaScript components.
Getting ready
For this recipe, we will continue using the my_library
module from the previous recipe. We will add a QUnit test case for the int_color
widget.
How to do it...
Follow these steps to add JavaScript test cases to the int_color
widget:
- Add
/static/tests/colorpicker_tests.js
with the following code:odoo.define('colorpicker_tests', function (require) { "use strict"; var FormView = require('web.FormView'); var testUtils = require('web.test_utils&apos...