Hello all,
In order to improve the stability on the UI side, we have added a new framework for UI testing.
Highlights
- We are using QUnit to write the tests, Selenium with Chromedriver to run the tests.
- All the tests will be in the
tests/ui
folder of the app - Tests will be run via a DocType Test Runner which will be called by Selenium on the CI. You can also test locally from the Test Runner interface
- Lots of core functions have been changed to return
Promise
objects, so that they can be gracefully triggered serially withfrappe.run_serially
- Helper functions to quickly edit forms.
- Easily build test fixtures (like Customers, Items etc) by passing simple JSON objects.
Next Steps
- We will be preparing a plan to build tests for most of the core Frappe and ERPNext features.
- We will start insisting on test cases for new contributions
Sample Test
QUnit.test("test quotation", function(assert) {
assert.expect(2);
let done = assert.async();
frappe.run_serially([
() => frappe.tests.setup_doctype('Customer'),
() => frappe.tests.setup_doctype('Item'),
() => {
return frappe.tests.make('Quotation', [
{customer: 'Test Customer 1'},
{items: [
[
{'item_code': 'Test Product 1'},
{'qty': 5}
]
]}
]);
},
() => {
// get_item_details
assert.ok(cur_frm.doc.items[0].item_name=='Test Product 1');
// calculate_taxes_and_totals
assert.ok(cur_frm.doc.grand_total==500);
},
() => done()
]);
});