-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
todo
property on assertions feels incorrect
#105
Comments
This reasoning seems sound. It was added to assertions data originally because the first implementation within QUnit required it to be present due to the way some of the test reporters work. That said, it should not be a required field due to the reasons you list above. |
Proposing we make this optional (or simply remove) in the next major release. I'm interested to know what makes it hard to track in Chai. I completely agree on the separation of concerns and that Chai shouldn't have to track this state. I'm just curious as to why it would be difficult, as that might lead us to uncover a deeper compat issue or difference to be aware of and for us to document internally. In particular, because consumers of js-reporters do need to know this information about each high-level test wrapper and will generally have that information available indirectly for each assertion, so that they could e.g. generate a nested or flat results lists as they wish where any test-information is repeated (e.g. by prefixing the suite names and test names, and their skipped/todo status etc.). Would that not be possible either? @keithamus Could you elaborate on why Chai can't know about this state? |
I propose that we simply remove it entirely from assertion object. The spec allows additonal non-standard properties to exist, so this would be a backwards-compatible change to make. Even on QUnit it is always decided per-test, it cannot be set per-assertion. One thing to keep in mind is how reporters need to read the "todo" status. I recently rediscovered karma-runner/karma-qunit#111 which suggests at least in the past there was confusion over how a reporter is meant to consume "todo" event data - where Karma currently wrongly fails the build due to perceiving the todo failures as real failures. |
Chai is an assertion library, not a test runner. It has no knowledge of the test runner under execution; it could be jest, ava, mocha, even QUnit. The only way for Chai to know if a test is |
@keithamus Thanks, that makes perfect sense indeed. Do you see Chai or other assertion libraries as potentially implementing some part of the CRI spec? Perhaps this was obvious, but I had not previously thought of the "Assertion" event data (emitted by test runners), and the assertion exceptions (thrown by Chai) as potentially being one and the same. As said, It may still need a mapping step for other sources of errors such as uncaught non-assert runtime errors, rejected promises, manually recorded errors (QUnit), or from non-conforming assertion libraries. But it'd be pretty cool not to need that in the general case. |
* This is redundant with the information already available in in the TestEnd event data. * We don't know of any testing frameworks that support flipping the "todo" status on a per-assertion basis, nor does that seem likely in the future as "Todo test" is defined as a test with one or more expected failures. * Presence of this in the spec was a barrier to entry as it means common assertion exception objects would require being cloned, mutated, or otherwise mapped to set accordingly. Fixes #105.
* This is redundant with the information available in in the TestEnd event data. * We don't know of any testing frameworks that support flipping the "todo" status on a per-assertion basis, nor does that seem likely in the future as "Todo test" is defined as a test with one or more expected failures. * Presence of this in the spec was a barrier to entry as it means common assertion exception objects would require being cloned, mutated, or otherwise mapped to set accordingly. Fixes #105.
This was already in the spec, but the test was extra strict, which would have caused other compliant implementations to fail our test. Also add a test for the names of tests and suites before we compare arbitrary offsets in the result arrays. This makes off-by-one failures less confusing to debug. Ref #105.
@Krinkle the desire is the next major version of Chai (v5) will implement 3.5 Assertion events as part of the CRI. Any failed assertion will emit an assertion event (and if there are no listeners to that event it'll throw). In a CRI world, I would expect assertion library agnostic runners such as Mocha to simply reflect events coming from assertion libraries like Chai - in other words they wouldn't create Assertion event objects, merely listen to the assertion libraries events and re-dispatch them on their own event bus. Although I'm not an author of a test runner library, I would imagine for uncaught non-assert runtime errors, marking the TestEnd event as failed would be sufficient. Perhaps it should be allowed that |
* This is redundant with the information available in in the TestEnd event data. * We don't know of any testing frameworks that support flipping the "todo" status on a per-assertion basis, nor does that seem likely in the future as "Todo test" is defined as a test with one or more expected failures. * Presence of this in the spec was a barrier to entry as it means common assertion exception objects would require being cloned, mutated, or otherwise mapped to set accordingly. Fixes #105.
In the current readme, assertion objects have a
todo
parameter - indicating whether or not this was part of a todo test. This feels invalid for a few reasons:skipped
isn't captured info in an assertion error. If skipped isn't, why is todo?"todo"
but my assertion object saystodo: false
? Which one do I believe?My suggestion is to remove the
todo
property from the assertion object, and have it only exist as a state on the test object.The text was updated successfully, but these errors were encountered: