Common need (assert list/result counts). Missing from the current assertion set.
Scope
- Add the
have.length case in src/asserts/index.ts (positive + negative messages, and the case in the switch). Accept a number as the expected length.
- Works on a single element against
el.children.length. If a collection variant is desired, leave a TODO for a follow-up.
- Add a unit test in
src/tests/asserts/.
- Add a row in
docs/api/assertions.md.
- Add a small list in
examples/twd-test-app/src/pages/Assertions.tsx with data-testid="have-length" and a sample in assertion-examples.twd.test.ts using screenDom.getByTestId(...) + twd.should(el, "have.length", 3).
Reference
- Mirror the
have.class implementation.
- Query pattern:
examples/twd-test-app/src/twd-tests/screen-queries.twd.test.ts.
Acceptance criteria
How to contribute
Read CONTRIBUTING.md first. Quick steps for this issue:
- Fork, clone, create a feature branch:
git checkout -b feat/have-length-assertion.
- From the repo root, build the library and sync it to the example apps:
npm install
npm run build
npm run copy:mock-sw
- Install and run the test app:
cd examples/twd-test-app
npm install
npm run dev
- Open the app in the browser — the TWD sidebar appears on the right. Run your new tests from the sidebar and confirm they pass.
- Run the library's unit tests from the repo root:
npm run test:ci.
- Open the PR with screenshots of the sidebar showing green tests.
Always prefer screenDom (Testing Library) for element queries. Avoid twd.get() in new code.
Common need (assert list/result counts). Missing from the current assertion set.
Scope
have.lengthcase insrc/asserts/index.ts(positive + negative messages, and thecasein the switch). Accept a number as the expected length.el.children.length. If a collection variant is desired, leave a TODO for a follow-up.src/tests/asserts/.docs/api/assertions.md.examples/twd-test-app/src/pages/Assertions.tsxwithdata-testid="have-length"and a sample inassertion-examples.twd.test.tsusingscreenDom.getByTestId(...)+twd.should(el, "have.length", 3).Reference
have.classimplementation.examples/twd-test-app/src/twd-tests/screen-queries.twd.test.ts.Acceptance criteria
npm run test:ciis green.twd-test-app.docs/api/assertions.mdupdated.How to contribute
Read CONTRIBUTING.md first. Quick steps for this issue:
git checkout -b feat/have-length-assertion.cd examples/twd-test-app npm install npm run devnpm run test:ci.