Skip to content

Commit 4463f38

Browse files
novemberbornsindresorhus
authored andcommitted
Refactor assertions
* Use our own AssertionError class. Now we can track the assertion rather than abusing the operator field. We can also stop depending on `core-assert` once we implement `t.throws()` ourselves. Reserve the `statements` property for power-assert output * Directly create `AssertionError`s, making it easier to specify the varying options * Default the assertion message to an empty string, removing workarounds in the mini and verbose reporters * Improve `t.plan()` assertion errors. Specify 'plan' as the assertion, and use `===` as the operator * Refactor `t.throws()` and `t.notThrows()`, improving readability and fixing #1227 * Move knowledge of when to show output into `serialize-error.js`. It sat kind of awkwardly in `assert.js` * Always try to format errors in mini and verbose reporters, check if actual / expected values are available when formatting * Wrap assertions in `assert.js` for use with the `ExecutionContext` * Only enhance the power-assert assertions, don't use `empower-core` to wrap the others * Remove superfluous `empower-core` 'originalMessage' handling. Our assertions create `AssertionError`s with the correct message * Refactor overloaded `Test#_assert()` method and assertion tracking internals. Note that only `t.throws()` and `notThrows()` are (possibly) asynchronous
1 parent 3aeb8b0 commit 4463f38

File tree

16 files changed

+555
-528
lines changed

16 files changed

+555
-528
lines changed

index.js.flow

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ type AssertContext = {
6363
};
6464
// Assert that function doesn't throw an error or promise resolves.
6565
notThrows: {
66-
<U>(value: PromiseLike<U>, message?: string): Promise<U>;
66+
(value: PromiseLike<mixed>, message?: string): Promise<void>;
6767
(value: () => mixed, message?: string): void;
6868
};
6969
// Assert that contents matches regex.

0 commit comments

Comments
 (0)