Skip to content

Commit

Permalink
feat: add skip cheatcode docs (#938)
Browse files Browse the repository at this point in the history
  • Loading branch information
Evalir authored Jun 28, 2023
1 parent 132a3bf commit 4f3a954
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@
- [Utilities](./cheatcodes/utilities.md)
- [`addr`](./cheatcodes/addr.md)
- [`sign`](./cheatcodes/sign.md)
- [`skip`](./cheatcodes/skip.md)
- [`label`](./cheatcodes/label.md)
- [`deriveKey`](./cheatcodes/derive-key.md)
- [`parseBytes`](./cheatcodes/parse-bytes.md)
Expand Down
3 changes: 3 additions & 0 deletions src/cheatcodes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,9 @@ interface CheatCodes {
// Sets an address' code
function etch(address who, bytes calldata code) external;
// Marks a test as skipped. Must be called at the top of the test.
function skip(bool skip) external;
// Expects an error on next call
function expectRevert() external;
function expectRevert(bytes calldata) external;
Expand Down
32 changes: 32 additions & 0 deletions src/cheatcodes/skip.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
## `skip`

## Signature

```solidity
function skip(bool skip) external;
```

## Description

Marks a test as skipped, conditionally. It must be called at the top of the test to ensure it is skipped without any execution.

If `skip` is called with a false boolean, it will not skip the test.

Tests marked as skipped will appear with a `[SKIPPED]` label on the test runner and on the summary, to easily identify skipped tests.

### Examples

```solidity
function testSkip() public {
cheats.skip(true);
/// This revert will not be reached as this test will be skipped.
revert("Should not reach this revert");
}
function testNotSkip() public {
cheats.skip(false);
/// This revert will be reached as this test will not be skipped, and the test will fail.
revert("Should reach this revert");
}
```

0 comments on commit 4f3a954

Please sign in to comment.