(obsolete) New UI Testing Framework!

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 with frappe.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 :slight_smile:

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()
	]);
});

Test Runner

Pulls

https://github.com/frappe/frappe/pull/3565

https://github.com/frappe/erpnext/pull/9532

28 Likes

Note that starting with v11, ERPNext moved from the QUnit and Selenium test framework to Cypress, as introduced here Bringing back UI Tests using Cypress