fix!(runner): correctly process custom tasks, update runner hooks naming#4076
Merged
sheremet-va merged 4 commits intovitest-dev:mainfrom Sep 29, 2023
Merged
Conversation
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.
Description
This is a breaking change. Previous support for custom tasks has been rewritten a little bit.
Fixes #3404
onAfterRunTestis nowonAfterRunTaskand so on,onBeforeRunandonAfterRunare now namedonBeforeRunFilesandonAfterRunFiles). They now also accept tasks with type "custom" (the shape of the object is identical)getCurrentSuite().task()instead ofgetCurrentSuite().custom(). It now accepts a second arguments which are options. You can pass down handler ashandlerinstead of saving it usingsetFn. If you usedcreateChainablebefore, you can spreadthisin options instead of callingcustom.call(this)- this now has no effect, it no longer relies onthisat all:createTaskCollectorutility - this will define a function that supportstodo/skip/each/skipIf/runIfand other.testchainables. The difference withcreateChainableis that you don't need to specify what you need to support, and it also supports more methods (each/runIf/skipIf):SnapshotClientnow accepts options - instead of overridingequalityCheckyou need to pass downisEqualfunction. If you don't rely on.toMatchSnapshot({ ... })tests (checking an object shape AND a snapshot string), you don't need to pass anything.SnapshotClientwere renamed to better represent what they do:setTest->startCurrentRun,resetCurrent->finishCurrentRun(you need to call.assertbetween those two calls)context.meta. It was deprecated for some time, please usecontext.taskinstead.And now it actually works :)
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
pnpm-lock.yamlunless you introduce a new test example.Tests
pnpm test:ci.Documentation
pnpm run docscommand.Changesets
feat:,fix:,perf:,docs:, orchore:.