QUnit Test Best Practices for UI5
When to load each reference
Load the reference before producing any output. Do not work from memory.
Core rules (always apply)
Quick-reference checklist
Use when authoring or reviewing a QUnit test file:
- No
var- useconstorlet; one declaration per line (no comma chains) - No
.bind(this)- use arrow functions for callbacks that do not need their ownthis - No
assert.async()in simple cases - useasync function+await new Promise(...) - Every
asynctest hasassert.expect(N) - No
sinon.sandbox.create()in new code - usesinon.createSandbox()or the bridge (this.stub(),this.spy(),this.mock());this.clockonly when fake timers are enabled - No
"it should..."test titles - use descriptive sentences - Every
QUnit.modulehasbeforeEach/afterEachthat create and destroy all controls - With fake timers: prefer
await nextUIUpdate(this.clock)overCore.applyChanges(); only keepCore.applyChanges()whennextUIUpdate(clock)cannot handle the case - Helper functions that create controls destroy them in
try/finally - No non-ASCII characters in comments or strings (UTF-8 required, but non-ASCII causes encoding issues)

