Commit graph

34 commits

Author SHA1 Message Date
Mark Wubben
9f3bf7e4d3
Remove references to older AVA versions
* Remove obsolete recipes

ES modules is supported out of the box.

The React recipe applies to AVA 3.

* Remove code guards against obsolete API usage

* Remove references to older AVA versions from documentation
2023-12-30 20:58:44 +01:00
Mark Wubben
b6fbd5847a Make assertions throw
Fixes #3201.

Assertions now throw a `TestFailure` error when they fail. This error is not exported or documented and should not be used or thrown manually. You cannot catch this error in order to recover from a failure, use `t.try()` instead.

All assertions except for `throws` and `throwsAsync` now return `true` when they pass. This is useful for some of the assertions in TypeScript where they can be used as a type guard.

Committing a failed `t.try()` result now also throws.
2023-10-22 21:40:24 +02:00
Aditya Subramanian
e81f413f5a
Allow throws / throwsAsync to work with any value, not just errors
Fixes #2517.

Co-authored-by: Mark Wubben <mark@novemberborn.net>
2023-09-11 13:12:20 +02:00
Richard Gibson
c988e27400
Support Symbol keys and ignore non-enumerable properties in t.like()
Fixes #3208

Co-authored-by: Mark Wubben <mark@novemberborn.net>
2023-06-16 17:38:43 +02:00
Tommy
d7c612047a
Support arrays in t.like() assertion
Co-authored-by: Mark Wubben <mark@novemberborn.net>
2023-05-24 15:17:16 +02:00
Forresst
b208d143ad
Link to correct branch in ava-docs repository 2022-06-02 14:08:58 +02:00
il3ven
e387cba63c
Support message testing function in throws & throwsAsync assertions 2022-05-16 10:43:44 +02:00
冯磊
f8be1528fd
Fix function reference in t.try() assertion documentation 2022-04-04 16:56:54 +02:00
Scott Martin
576f534b34
Update examples in docs to use ES Modules
Co-authored-by: Mark Wubben <mark@novemberborn.net>
2022-02-13 19:48:45 +01:00
John Rayes
1cda8c7e69
Refer to assertion inputs as "actual" 2022-01-23 19:12:31 +01:00
Mark Wubben
f09742f7ba
Clean up documentation in preparation for AVA 4 2022-01-03 18:42:58 +01:00
Ikko Ashimine
9717f2ba41
Fix typo in assertions documentation 2021-10-23 18:42:34 +02:00
Mark Wubben
678f9caf22 Remove Babel support, and therefore enhanced assertions
This removes support for @ava/babel. Since enhanced assertions (power assert)
are provided through that package this also removes support for those. Same for
improper throws detection.

@ava/babel has seen no meaningful contributions since it was released at the
start of 2020. It's not clear how we'd make it work with ESM. It's clearer if we
can recommend tools like @babel/register and otherwise focus on plain Node.js &
TypeScript support.
2021-09-19 17:15:03 +02:00
Matthew Espino
dc93f372e6
Return undefined when throws assertions fail 2021-08-22 19:58:45 +02:00
Mark Wubben
dd997f827d Return null when throws() and throwsAsync() assertions fail
Make the behavior explicit in the documentation and type definition.
2021-07-10 15:41:20 +02:00
Mark Wubben
d7c2b90ae4 Remove support for passing multiple test implementations
This affects test() and t.try().

Supporting multiple implementations made both the implementation and the
type definitions needlessly complex. Using for/of syntax it's easy
enough to declare tests (or t.try() attempts) with the same arguments.
2021-07-10 15:41:20 +02:00
Mark Wubben
8571b2a7f7 Remove test.cb()
Fixes #2387.
2021-03-14 08:50:47 +01:00
ninevra
14ec281dd6
Introducing AVA snapshots v3
The v3 format is encoded using CBOR. It contains all information necessary to regenerate the report file. This allows for snapshots to be updated even if tests or assertions are skipped.

This is not backwards compatible with the v2 format used in AVA 3.

Co-authored-by: Mark Wubben <mark@novemberborn.net>
2021-03-13 17:21:53 +01:00
Mark Wubben
61ded90ce3
Snapshot assertions do not return booleans 2021-03-07 20:05:50 +01:00
jmarkham828
72a4e2fd4c
Return booleans indicating whether assertions passed
Co-authored-by: Mark Wubben <mark@novemberborn.net>
2021-03-07 17:09:55 +01:00
ninevra
d8b1e89e6e
Remove support for snapshot IDs 2021-02-13 16:24:48 +01:00
Mark Wubben
26999c4cca Remove built-in React support
To be provided through a plugin instead.
2021-02-07 16:54:28 +01:00
John Simoni
f328a6933a
Experimentally disable null expectations for throws assertions 2020-09-09 09:29:06 +02:00
Mark Wubben
fac7990ea4 Unflag t.like() assertion 2020-07-27 09:03:56 +02:00
futpib
19c4f35fba
Experimentally implement t.like() assertion
Co-authored-by: Mark Wubben <mark@novemberborn.net>
2020-06-14 15:45:26 +02:00
Mark Wubben
12ba7bcd67 Ship t.try() without requiring opt-in
This removes the tryAssertion experiment.
2020-02-23 16:41:02 +01:00
Nikita Volodin
324e45f2f8
Document t.try() (#2251)
Co-authored-by: Mark Wubben <mark@novemberborn.net>
2020-02-16 16:38:37 +01:00
Sindre Sorhus
090884b504 Use question mark to indicate optional argument in docs 2020-01-07 10:31:29 +01:00
Mark Wubben
7f99aef61f Remove legacy .throws() and .throwsAsync() interfaces
Fixes #2301.
2020-01-05 16:02:55 +01:00
Mark Wubben
79b2ea30c1 Use CJS syntax in documentation
Out of the box, ESM syntax will only work in Node.js 13, so having that
as the default example is misleading.

Leave it for the TypeScript recipe since TypeScript doesn't work out of
the box anyway. Leave the config example, which will be updated when we
update the config formats for ESM.
2019-12-31 15:33:43 +01:00
Mark Wubben
b4ea43529a
Remove built-in Babel support
This updates code and tests to remove built-in Babel support. In the
future, it needs to be opted in to, and @ava/babel needs to be installed
besides AVA itself.

Our tests have become quite muddled, and some of them require Babel to
still be enabled, but that's all OK for now.

* Remove outdated JSPM recipe

* Update documentation to reflect the removal of built-in Babel

* Move responsibility for power-assert to @ava/babel
2019-12-24 17:46:45 +01:00
Eeme
9406470283 Only apply power-assert to new t.assert() assertion 2019-03-24 16:24:31 +01:00
Forresst
f4b2d196e8 Fix links to French translation of docs (#2005) 2018-12-31 15:14:30 +01:00
Mark Wubben
1ba31d8f3e
Reorganize documentation
Extract various sections from the readme into their own files. I've tried to keep other changes to a minimum.

Remove the lone RFC. Likely, we'd reintroduce RFCs in a separate repo.
2018-11-05 09:08:04 +00:00