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

🧹 Add expect-based tests for interactive scripts #389

Merged
merged 2 commits into from
Feb 12, 2024
Merged

Conversation

janjakubnanista
Copy link
Contributor

@janjakubnanista janjakubnanista commented Feb 12, 2024

In this PR

  • Adding expect-based testing suites for interactive hardhat tasks. expect is a utility that makes testing interactive commands easy by listening to the output and reacting to it by sending input. It is a way of testing the tasks in isolated runtime (in their own shell) while still being able to "mock" user inputs.

expect utility should be preinstalled on mac - if not, it can be installed using e.g. homebrew. On unix systems, it also comes with an autoexpect utility that will "record" the expected interaction and turn it into a test script.

The test scripts themselves are written in an interpreted language Expectk. It has some quite advanced control flow features but for us the expect and send instructions are the two go-to ones. There's a nice little tutorial for expect here

@ryandgoulding ryandgoulding merged commit 3ca8eb9 into main Feb 12, 2024
5 checks passed
@ryandgoulding ryandgoulding deleted the expect branch February 12, 2024 23:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants