Commit graph

65 commits

Author SHA1 Message Date
Mark Wubben
3ebe65cbeb
Re-organize types for maximum compatibility
Add shims for TypeScript's 'node' module resolution algorithm. The exports map is only used with the `node16` algorithm.

Write types in CommonJS, so they can be exported from ESM files. The other way around is prone to, at the very least, confusing warnings.
2022-09-25 16:31:54 +02:00
Mark Wubben
02f4e27b53
Rely on TypeScript 4.7 and update integration + tests
* Only test against TypeScript 4.7

* Move type definitions to entrypoints/

Only TS 4.7 will resolve them now, but it's cleaner.

* Use @sindresorhus/tsconfig

* Fix test TypeScript files, make compilable and lintable

* Use tsc directly, instead of tsd

* Add *.cts versions of type tests

* Reorganize type tests

* Use tsc directly, avoid npx, print actual version

Somehow `npx tsc` was pointing at an older version. Possibly the binstubs are corrupted in CI… somehow.
2022-07-10 18:30:04 +02:00
Rebecca Stevens
c218a210a1
Fix TS 4.7 compatibility
Export type definitions for CJS imports, make the existing ESM definitions discoverable by TS 4.7.

Co-authored-by: Mark Wubben <mark@novemberborn.net>
2022-06-02 14:04:40 +02:00
Mark Wubben
4b4b2f63f1 Refactor type definition
* Split across multiple files.

* Rename types, most noticeably `TestInterface` is now `TestFn`, but
really anything that had the Interface suffix has been changed.

* Update some documentation.
2021-07-10 15:41:20 +02:00
Mark Wubben
8efb9d149d Change implementation argument type constraint to unknown
This mostly impacts macros, for which we'd want to encourage explicit types.
2021-07-10 15:41:20 +02:00
Mark Wubben
fadc6c8a52 Add test.macro(), change how macros are typed
Fixes #2189. `test.macro()` returns an object that can be used with
`test()` and hooks. The `t.context` type is inherited from `test`.

Like with AVA 3, regular functions that also have a `title` property
that is a string-returning function are supported. However this is no
longer in the type definition.

Instead the recommended approach is to use `test.macro()` to declare
macros. At a TypeScript level these are easier to discriminate from
regular implementations.
2021-07-10 15:41:20 +02:00
Mark Wubben
a8cbfb7229 Change constructor type for instanceOf expectation
It should result in an error.
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
5e0844452f Explicit and separate CJS and ESM entrypoints
Fixes #2671.

AVA now only has a default export: the test() function.
2021-03-28 19:34:48 +02:00
Mark Wubben
8571b2a7f7 Remove test.cb()
Fixes #2387.
2021-03-14 08:50:47 +01:00
Mark Wubben
5eea608364 Turn assertions into type guards
Update the `deepEqual`, `like`, `false`, `true` and `is` assertions so
they can be used as type guards. Fixes #2456.

Change the `deepEqual`, `like` and `is` assertions so the actual and
expected parameters can be typed separately. Fixes #2580.
2021-03-07 17:32:14 +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
69fbe05894 Upgrade XO and apply fixes 2021-02-07 16:54:28 +01:00
Mark Wubben
41a47bf258
Update dependencies
* Update dev dependencies

* Update XO

* Update dependencies

* Rebuild lockfile
2020-08-23 21:37:45 +02:00
Mark Wubben
eee2f7b720 Fix t.like() selector type
See https://github.com/avajs/ava/issues/2518#issuecomment-651771859
2020-07-04 15:15:00 +02:00
Jonathan Samines
ca8ea45587
Support assertion message in t.timeout()
Fixes #2443.

Co-authored-by: Mark Wubben <mark@novemberborn.net>
2020-07-04 13:58:33 +02:00
Mark Wubben
f06c506d32
Update dependencies; supported Node.js versions
* Remove Node.js 13 support

* Denote Node.js 12.17 as the future minimal Node.js 12 version

* Update dev dependencies

* Upgrade XO

* Update dependencies

* Rebuild lockfile
2020-06-14 16:38:58 +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
Oskar Löfgren
75cbc3b2a5
Add t.teardown()
Co-Authored-By: Mark Wubben <mark@novemberborn.net>
2020-04-26 15:58:15 +02:00
Oskar Löfgren
cb5f9f7087
Expose snapshot directory through test.meta
Fixes #1984.

Co-authored-by: Mark Wubben <mark@novemberborn.net>
2020-04-10 16:22:09 +02:00
Mark Wubben
489b13e0be Fix TypeScript documentation for t.try() 2020-04-04 16:43:21 +02:00
Bunyanuch Saengnet
8f312c0f2c
Add t.passed to execution contexts
In `afterEach` hooks, consult `t.passed` to determine whether the test passed.

Fixes #840.

Co-authored-by: Mark Wubben <mark@novemberborn.net>
2020-04-04 14:53:14 +02:00
Mark Wubben
60784a5138 Upgrade XO 2020-03-30 10:22:52 +02:00
Stav Alfi
d0e2161239
Support undefined as second argument to t.throws and t.throwsAsync 2020-02-23 16:02:11 +01:00
Mark Wubben
7a1dacf369
Remove @types/node reference
Fixes #2397.

* Remove @types/node reference from our TypeScript definition

* Ensure our TypeScript tests don't use any installed types

* Adjust our TypeScript test target to ES2018
2020-02-16 13:03:49 +01:00
Mark Wubben
7f99aef61f Remove legacy .throws() and .throwsAsync() interfaces
Fixes #2301.
2020-01-05 16:02:55 +01:00
Micaël Mbagira
b78c71d5d0 Type observables based on how they're consumed by AVA
Detect subscribables and convert to promise. Simplify type description to match what AVA actually requires.

Co-authored-by: Mark Wubben <mark@novemberborn.net>
2020-01-05 12:05:28 +01:00
Nikita Volodin
4fdb02dd66 Implement experimental t.try() assertion 2019-09-08 21:37:33 +02:00
Mark Wubben
2fc7d56475 Change default Context type to unknown 2019-07-15 20:32:56 +01:00
Sindre Sorhus
bb44da714b Explicitly reference the Node.js type definition 2019-06-10 16:24:59 +02:00
Alexis Fontaine
ba5cd80484 Fix TypeScript definition allowing macro-without-title-using-tests to be skipped 2019-05-19 14:28:58 +02:00
Sindre Sorhus
c2d8218ba7 Improve the TypeScript definition ObservableLike type
Fixes #1685
2019-05-05 16:13:19 +02:00
Nikita Volodin
ebf480779b Simplify macro types in TypeScript definition 2019-04-06 17:17:09 +02:00
Mark Wubben
a7605dec23 Add t.assert() to type definitions 2019-03-27 09:29:24 +01:00
Daniel Lupu
b65c6d7da8 Add t.timeout()
Fixes #1565
2019-01-26 17:51:38 +01:00
Corey Farrell
bccd297f38 Expose test file path within worker process
This adds `test.meta.file` which exposes the filename of the test being run by AVA.

Fixes #1976
2019-01-13 11:34:42 +01:00
Jamie
311c197d71 Fix snapshot skip interface 2018-11-25 18:16:02 +00:00
Mark Wubben
6f54db8419
Type additional arguments used by macros
Co-authored-by: Nikita Volodin [Никита Володин] <volodin.n@gmail.com>
2018-11-11 15:08:32 +00:00
Mark Wubben
aa35f154e7
Pass an undefined title argument to macro-title functions
Previously, AVA would pass the empty string. By passing an undefined value, the title function can use argument defaults which is more natural.

This is a breaking change for users who were concatenating `title`, under the assumption it was an empty string.
2018-10-28 16:52:39 +00:00
Mark Wubben
7be3f995c9
Better typing for throws assertions
Fixes #1893.
2018-10-14 15:26:21 +01:00
Oky Antoro
7f974ccd1f Allow code in throws expectations to be a number
Fixes #1901.
2018-08-14 09:44:09 +01:00
Mark Wubben
7babf6be0f Move promise-handling code to t.throwsAsync and t.notThrowsAsync
References #1794.
2018-07-27 14:21:42 +01:00
Mark Wubben
d5dd981d02 Remove observable support in t.throws() and t.notThrows()
See discussion in #1794. It feels out of place compared to promises and
requires many overloads in the type definitions.
2018-07-14 16:31:25 +01:00
Mark Wubben
d7c6b3ded6 Remove test export
Fixes #1862. The test() method is already available as the default export.
2018-07-14 15:21:56 +01:00
Mark Wubben
02d768f0f8 Remove support for iterators returned by test implementations
See discussion in #1794. This is a remnant of the days before async/await.
2018-07-14 15:21:39 +01:00
Mark Wubben
673f81c398 Fix type comment for message expectation 2018-05-31 18:47:20 +01:00
Mark Wubben
b91f7e0da8 Add type definitions for code expectation 2018-05-31 18:47:20 +01:00
Mali Michael
53fb487e6b Add inline docs to Assertions interfaces 2018-04-08 14:04:23 +01:00
Arjay Sitoy
ecc219ae31 Add inline docs to test interface type definitions
Fixes #1686.

Updates the assertion skipping type definitions to be in line with the actual implementation.

Allow `.end()` in `CbExecutionContext` to take an error value.

Fix hook typing so it's clearer plain implementations can be used without a title. This was possible before through a macro, which was misleading.

Co-authored-by: Arjay Sitoy <sitoy.arjay@gmail.com>
Co-authored-by: Mark Wubben <mark@novemberborn.net>
2018-03-08 15:35:22 +00:00