Uh oh!
There was an error while loading. Please reload this page.
This repository was archived by the owner on Nov 2, 2025. It is now read-only.
Add t.before(fn) method - #28
Merged
Merged
Conversation
While the recommendation in the past has been 'use t.test() for this', it's really annoying to have to specify `-g 'setup|my test'` when running a single test for debugging. Also, you might not want to have assertions for these; often just a simple pass/fail is enough, and can keep the test output a bit quieter. `t.before(fn)` is effectively a single (optionally promise-returning) function which can be run before all tests and assertions, and which is immune to any filters. If the `t.before(fn)` function throws or rejects, is called more than once, or is called after any tests or assertions, then the test fails.
coreyfarrellforce-pushed
the
isaacs/before-fn
branch
from
February 16, 2021 13:55
a9ad541 to
a75fe4cComparecoreyfarrell
commented
Feb 16, 2021
Member
Side note I'm really liking TLA in ESM based tests for this purpose. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Based on #27, land that first.
While the recommendation in the past has been 'use t.test() for this',
it's really annoying to have to specify
-g 'setup|my test'whenrunning a single test for debugging. Also, you might not want to have
assertions for these; often just a simple pass/fail is enough, and can
keep the test output a bit quieter.
t.before(fn)is effectively a single (optionally promise-returning)function which can be run before all tests and assertions, and which is
immune to any filters.
If the
t.before(fn)function throws or rejects, is called more thanonce, or is called after any tests or assertions, then the test fails.