feat: add per-task untimed lifecycle hooks#33
Merged
Aslemammad merged 6 commits intotinylibs:mainfrom Mar 4, 2023
Merged
Conversation
Adds four lifecycle hooks that can be configured to run on a per-task
basis without impacting the test timings:
- `before`: run once before iterations of the task start
- `beforeEach`: run before each iteration of the task
- `afterEach`: run after each iteration of the task
- `after`: run after all iterations finish
A contrived example:
```js
suite.add('my task', async () => {
// the timed function
}, {
before: () => {
// start a server
},
beforeEach: () => {
// set up some data that the timed function will mutate
},
afterEach: () => {
// tear down any mutated data
},
after: () => {
// stop the server
}
})
```
This is useful if, for example, you are testing several implementations
of the same functionality and need to perform different operations on
each implementation to bring them into the same state that the timing
data from the task function is useful data.
Closed
achingbrain
commented
Feb 21, 2023
| "eslint-plugin-import": "^2.26.0", | ||
| "nano-staged": "^0.5.0", | ||
| "size-limit": "^8.0.1", | ||
| "size-limit": "^7.0.8", |
Contributor
Author
There was a problem hiding this comment.
Without this change, npm i fails with:
% npm i
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: tinybench@2.3.1
npm ERR! Found: size-limit@8.2.4
npm ERR! node_modules/size-limit
npm ERR! dev size-limit@"^8.2.4" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer size-limit@"7.0.8" from @size-limit/preset-small-lib@7.0.8
npm ERR! node_modules/@size-limit/preset-small-lib
npm ERR! dev @size-limit/preset-small-lib@"^7.0.4" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR!
npm ERR! For a full report see:
npm ERR! /Users/alex/.npm/_logs/2023-02-21T11_08_37_616Z-eresolve-report.txt
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/alex/.npm/_logs/2023-02-21T11_08_37_616Z-debug-0.logIf you update size-limit, @size-limit/preset-small-li and @size-limit/time all to the latest versions, conflicting versions of esbuild are pulled in which tsup tries to pass the watch flag to - this was recently removed and errors out, so the simplest thing to do here seems to be to downgrade size-limit.
Contributor
Author
|
I've changed the names |
Contributor
Author
|
@Aslemammad are there any changes you'd like to be made or is there anything else I can do here? |
Member
|
It's good for now, soon on the weekend i'll review it and let you know
…On Mon, 27 Feb 2023, 21:18 Alex Potsides, ***@***.***> wrote:
@Aslemammad <https://github.com/Aslemammad> are there any changes you'd
like to be made or is there anything else I can do here?
—
Reply to this email directly, view it on GitHub
<#33 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AJBMICBP5Z3U3ITRBPXV4UTWZTSG5ANCNFSM6AAAAAAVC44QSI>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
achingbrain
added a commit
to ipfs/helia
that referenced
this pull request
Mar 4, 2023
tinylibs/tinybench#33 has been merged so update the minimum used version
Member
|
Thank you so much, I forgot to write this one :) |
achingbrain
added a commit
to ipfs/helia
that referenced
this pull request
Mar 9, 2023
tinylibs/tinybench#33 has been merged so update the minimum used version
4 tasks
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 free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Adds four lifecycle hooks that can be configured to run on a per-task basis without impacting the test timings:
beforeAll: run once before iterations of the task startbeforeEach: run before each iteration of the taskafterEach: run after each iteration of the taskafterAll: run after all iterations finishA contrived example:
This is useful if, for example, you are testing several implementations of the same functionality and need to perform different operations on each implementation to bring them into the same state so that the timing data from the task function is useful data.
Fixes #32