Comments (5)
Sounds like an interesting idea. Unfortunately I don't see how this could be implemented. By the time the withDescription() method is called, the assertion has already run.
The position of the description is consistent btw. It's always the last argument.
from qunit-dom.
@Turbo87 I see - but "always the last argument" can be limiting for long-term growth of the API for an argument that is optional for every assertion. I know a few weeks ago when I looked at this library (when evaluating it for our use case) the exists
method didn't contain the options argument, which it now does (to support count
).
This could've been solved by making a backwards incompatible change, but that still would've required me (the app developer) to go through and replace/codemod all exists('my description')
with exists({}, 'my description')
.
Since it sounds like the assertion is run in the - I guess I'll call it - assertion method? What if we change the order on this? I can think of three possible options:
assert.dom('.my-toggle', 'The toggle button was clicked').exists();
assert.dom('.my-toggle', { description: 'The toggle button was clicked' }).exists();
assert.dom('.my-toggle').describedBy('The toggle button was clicked').exists()
As someone on the outside looking in, I believe I would prefer 2 over 1, but 3 would also be a very comfortable solution.
Thoughts?
from qunit-dom.
@seanjohnson08 as you can see in https://github.com/simplabs/qunit-dom/blob/a2c26d8bf3fa6cb33f968e1fe5577d79476c5d65/lib/assertions/exists.ts#L6-L9 the exists()
assertion also supports being called with just a description, so there was no backwards incompatible change.
RE 1) and 2) the issue is that the description describes the assertion, not the element that the assertion runs on so the description would be on the wrong thing
RE 3) can be confusing if people expect it to work in the other order too and has similar problems as above too
from qunit-dom.
Hmm, I see. I guess now that I know more about the conventions established:
- message is always the last argument, not always some N argument
- for lists of optional arguments, type checking is used to provide "overloading" to ensure all combinations are supported
I would be happy with closing this issue and maybe just adding the above ^ to the API.md as a way to educate / communicate this convention.
from qunit-dom.
@seanjohnson08 sounds like a good idea, yeah. the API.md
is auto-generated from the code comments though, so I'm not sure exactly where to add that comment, but feel free to experiment with it. I'll go ahead and close this issue as you're original concern seems to be addressed.
from qunit-dom.
Related Issues (20)
- Make it an npm package with 0 dependencies HOT 2
- Is there a way to customize how assertion messages determine the name of an element? HOT 3
- `doesNotHaveProperty` not implemented
- hasText() doesn't work on string like things
- hasStyle does not work for CSS variables HOT 4
- hasAnyText should trim white space? HOT 1
- default assert.dom rootElement HOT 3
- add method to query child elements
- Add `hasChild` method to assert that child element exists
- This whitespace replace regex is not replacing encoded whitespaces. HOT 3
- Issue with assert.dom(this.element) types with latest Ember and QUnit HOT 3
- "Unexpected Parameter" `TypeError` when `target` is undefined
- Assert css variable value? HOT 1
- Unable to use with Vite in non-ember projects HOT 12
- convert to v2 addon / real npm package HOT 1
- Add `hasHtml` to assert an element has specific HTML
- Does it makes sense to add vanilla / vanillajs to this project's tags? HOT 1
- Argument of type ShadowRoot | null is not assignable to parameter of type Element | undefined .
- PR 1976 was a breaking change but released as a minor update HOT 5
- Action Required: Fix Renovate Configuration
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from qunit-dom.