`expect.throws`
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 5.4k
- Forks
- 215
- Avg merge
- 2h 9m
- Merged PRs (30d)
- 27
Description
Use Case
Expect that a code block throws an error.
Proposed Solution
Proposed API:
inflight throws(block: inflight (): void, contains: str?);
throws(block: (): void, contains: str?);
The contains will partial match against the error message text (e.g. contains()).
We need a separate API for inflight and preflight because if this is an inflight closure it
is implicitly asynchronous, so it cannot be called preflight.
Example:
bring expect;
// this is the preflight version
expect.throws(() => { throw "my"; }); // `contains` is optional
test "an error is thrown" {
// this is the inflight version
expect.throws(() => {
throw "i am an error";
}, contains: "error");
}
Implementation Notes
No response
Component
No response
Community Notes
- Please vote by adding a 👍 reaction to the issue to help us prioritize.
- If you are interested to work on this issue, please leave a comment.
- If this issue is labeled needs-discussion, it means the spec has not been finalized yet. Please reach out on the #dev channel in the Wing Slack.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names no files, tests, or entry points. Start by reviewing the proposed preflight and inflight APIs and the surrounding expect functionality, then determine the finalized behavior for optional partial message matching. Done means both forms are specified and implemented with coverage for the shown synchronous and asynchronous examples.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100