Thursday, June 25, 2020
1 change · master
New functionality added to Odoo
The web module now checks whether test widgets are properly cleaned up after JavaScript unit tests. This helps prevent leftover test components from disrupting later tests, improving reliability for future development.
Original PR description
Widgets have to be explicitly destroyed in unit tests. Non-trivial widgets which are not properly destroyed can lead to odd issues and failings in following tests (e.g. because they're intercepting…
Widgets have to be explicitly destroyed in unit tests. Non-trivial widgets which are not properly destroyed can lead to odd issues and failings in following tests (e.g. because they're intercepting events, have timers running, or are otherwise interfering with the widgets actually being tested). This PR implements a "leak checker" of sorts: it records all the widgets created during the test, and fails if some of them are un-destroyed at the end. It also fixes extant instances of that issue. Note that this will not catch all such leak checks: if a widget is created in an async callback and the test is not marked async (aka it's created after the tests has ended as far as qunit is concerned) it won't be detected. It also doesn't handled the path issue: most tests only properly cleanup and terminate their tests in case no error happened (a deferred of some sort resolved correctly), this can cause cascading errors where one test failing would either lead to its timeout or interfere with further tests.