Skip to content
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

feat(cheatcodes): add skip cheatcode docs #938

Merged
merged 1 commit into from
Jun 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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");
}
```