Skip to content

feat(ui5): Add QUnit best-practices skill#80

Open
plamenivanov91 wants to merge 2 commits into
UI5:mainfrom
plamenivanov91:qunit-skill
Open

feat(ui5): Add QUnit best-practices skill#80
plamenivanov91 wants to merge 2 commits into
UI5:mainfrom
plamenivanov91:qunit-skill

Conversation

@plamenivanov91

Copy link
Copy Markdown

Adds the ui5-best-practices-qunit skill covering coding standards for OpenUI5/SAPUI5 unit test files. Follows the same structure as the OPA5 skill: a lean SKILL.md router plus three focused reference files loaded on demand by task type (writing new tests, modernizing existing ones, async patterns).

  • SKILL.md: trigger description with literal user phrases, core rules table, quick-reference checklist
  • references/writing-new-tests.md: module structure, AAA pattern, test naming, helpers, file setup (/*global QUnit */, sap.ui.define imports)
  • references/modernizing-tests.md: var/const/let, bind, assert.async, Core.applyChanges, sinon sandbox, assert.expect, import cleanup, encoding fix, what-not-to-change guard table
  • references/async-patterns.md: nextUIUpdate vs Core.applyChanges decision table (incl. fake-timer exceptions), waitForEvent, waitForRendering via addEventDelegate, when not to convert assert.async
  • README.md: adds ui5-best-practices-qunit section
  • plugin.json / .github/plugin/plugin.json: adds "qunit" keyword
  • All files ISO 8859-1 compliant (no em dashes or non-ASCII)

JIRA: BGSOFUIPIRIN-7067

@d3xter666 d3xter666 requested review from a team and flovogt June 23, 2026 14:33
Comment thread plugins/ui5/README.md

@flovogt flovogt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@codeworrior Could you have a look at this QUnit best practices, please?

@codeworrior codeworrior left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM, but IMO, there are still a few things to be clarified / added.

Comment thread plugins/ui5/skills/ui5-best-practices-qunit/references/async-patterns.md Outdated
Comment thread plugins/ui5/skills/ui5-best-practices-qunit/references/modernizing-tests.md Outdated
Comment thread plugins/ui5/skills/ui5-best-practices-qunit/references/modernizing-tests.md Outdated
Comment thread plugins/ui5/skills/ui5-best-practices-qunit/references/modernizing-tests.md Outdated
Comment thread plugins/ui5/skills/ui5-best-practices-qunit/references/writing-new-tests.md Outdated
Comment thread plugins/ui5/skills/ui5-best-practices-qunit/references/writing-new-tests.md Outdated
Comment thread plugins/ui5/skills/ui5-best-practices-qunit/SKILL.md Outdated
Comment thread plugins/ui5/skills/ui5-best-practices-qunit/SKILL.md
Adds the ui5-best-practices-qunit skill covering coding standards for
OpenUI5/SAPUI5 unit test files. Follows the same structure as the OPA5
skill: a lean SKILL.md router plus three focused reference files loaded
on demand by task type (writing new tests, modernizing existing ones,
async patterns).

- SKILL.md: trigger description with literal user phrases, core rules
  table, quick-reference checklist
- references/writing-new-tests.md: module structure, AAA pattern, test
  naming, helpers, file setup (/*global QUnit */, sap.ui.define imports)
- references/modernizing-tests.md: var/const/let, bind, assert.async,
  Core.applyChanges, sinon sandbox, assert.expect, import cleanup,
  encoding fix, what-not-to-change guard table
- references/async-patterns.md: nextUIUpdate vs Core.applyChanges
  decision table (incl. fake-timer exceptions), waitForEvent,
  waitForRendering via addEventDelegate, when not to convert assert.async
- README.md: adds ui5-best-practices-qunit section
- plugin.json / .github/plugin/plugin.json: adds "qunit" keyword
- All files ISO 8859-1 compliant (no em dashes or non-ASCII)

JIRA: BGSOFUIPIRIN-7067
…curacies

PR review feedback (flovogt, codeworrior):
- README: sort skills alphabetically (qunit after opa5)
- async-patterns: promote nextUIUpdate(clock) as the mainstream fake-timer
  approach (not a limited caveat); add nextUIUpdate.runSync() for sync helpers;
  replace "note in commit message" with per-occurrence inline comment guidance;
  fix import path to sap/ui/test/utils/nextUIUpdate; note deprecated
  sap/ui/qunit/utils/nextUIUpdate re-export (since 1.127); add legacy-free UI5
  warning; remove misleading placeAt() exception row
- modernizing-tests: expand §5 with bridge-vs-sandbox consistency rule and
  verifyAndRestore guidance; expand §7 to cover non-standard Core param names
  and sap.ui.getCore() distinction; soften §8 encoding wording from
  "must be ISO 8859-1" to "avoid non-ASCII"; update grep patterns to reflect
  real project layouts; add §9 QUnit 1 -> QUnit 2 globals migration
- writing-new-tests: add sinon bridge-vs-dependency consistency guidance,
  CPOUI5FOUNDATION-1204 note, fix grep path patterns
- SKILL.md: add QUnit 1 migration trigger, update sinon sandbox/bridge rule,
  fix fake-timer checklist item, soften encoding wording throughout
@plamenivanov91

plamenivanov91 commented Jul 1, 2026

Copy link
Copy Markdown
Author

Here is the original qUnit improvement pilot change 6566798 (Gerrit ID).

@flovogt

flovogt commented Jul 6, 2026

Copy link
Copy Markdown
Member

@plamenivanov91 please rebase

Check for all uses of the parameter bound to `sap/ui/core/Core` - it may be named `Core`, `oCore`, `CoreInstance`, or anything else. Remove it only when no usage of that parameter remains:

- `Core.byId(...)`, `Core.getConfiguration()`, `Core.getModel()`, etc.
- `sap.ui.getCore()` calls in the same file do **not** count as a usage of the imported parameter and do not prevent removal.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't agree to this. When sap.ui.getCore() is used mid-code, a dependency to sap/ui/core/Core should be maintained (or better, sap.ui.getCore() should be replaced with the dependency. Otherwise, sap.ui.getCore() is a hidden dependency to sap/ui/core/Core.

For bootstrap code (top level sap.ui.getCore().attachInit(...) or .ready(...)), replacement is more difficult and out of scope for this skill.

## 8. Fix non-ASCII characters

Replace em dashes (U+2014) and other non-ASCII characters in comments with plain ASCII hyphens. Files must be ISO 8859-1 compliant.
Replace em dashes (U+2014) and other non-ASCII characters in comments with plain ASCII hyphens. UTF-8 is the required encoding, but non-ASCII characters - especially in comments - have historically caused encoding issues (e.g. garbled output when the `<meta charset>` tag is missing). Keep comments and strings ASCII-only.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if non-ASCII characters are needed, use unicode escapes (e.g. \u00a0)

- **Via the QUnit-sinon bridge (preferred):** configured in the test starter; sinon is not imported as a dependency. Use `this.stub()`, `this.spy()`, `this.clock` from the QUnit context.
- **Via explicit dependency:** import sinon as a module dependency and do not configure it via the test starter. Do not use the bridge (`this.stub()` etc.) in this case.
- Add `/*global sinon */` only when sinon is used via the bridge (it arrives as a global, not an AMD module).
- Declare all other dependencies in `sap.ui.define`. Only import `sap/ui/core/Core` if `Core.byId`, `Core.getConfiguration`, or similar is used - do not import it just for `Core.applyChanges()` when `nextUIUpdate()` is used instead.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AS this file is about new tests: new tests shouldn't use the deprecated Core functions. byId, getConfiguration or similar, they should use the modern alternatives.

@codeworrior

Copy link
Copy Markdown
Member

Again, well done! Only a few comments remaining.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants