O'Reilly logo

Odoo Development Cookbook by Daniel Reis, Alexandre Fayolle, Holger Brunn

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Writing tests for client side code

The more code you have on the client side, the more it becomes a liability. For server side code, there's the well-entrenched unit tests, and for JavaScript, we have QUnit (https://qunitjs.com), which Odoo uses.

Getting ready

We'll add our tests to the addon developed in the previous recipes, so grab the code from the recipe Making RPC calls to the server and put it in a new module called ch15_r04.

How to do it...

We have to add our test file and make it known to the test mechanism in the appropriate template.

  1. Add the static/test/ch15_r04.js file:
    odoo.define_section('ch15_r04', ['ch15_r04'], function (test, mock) {
        test('FieldMany2OneButtons', function(assert, ch15_r04)
        {
  2. Create a minimal implementation of FieldManager ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required