-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
feat: introduce the new reporter API #7069
Draft
sheremet-va
wants to merge
43
commits into
vitest-dev:main
Choose a base branch
from
sheremet-va:feat/new-reporter-api
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,239
−761
Draft
Changes from 2 commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
38b967c
feat: introduce the new reporter API
sheremet-va 25bae18
chore: cleanup
sheremet-va 0998e4f
feat: introduce the new reporter API
sheremet-va 6f0da08
chore: cleanup
sheremet-va 64abbda
feat(reporters): add first 5/7 test run life cycles
AriPerkkio f3686b0
test: add initial test setup
AriPerkkio 9cd58e9
fix: report skipped tests, prevent duplicate queued
AriPerkkio 3f6edd5
fix: review
AriPerkkio 1b8264a
Merge branch 'feat/new-reporter-api' of github.com:sheremet-va/vitest…
sheremet-va 506cec5
refactor: don't allow undefined in getReportedEntity
sheremet-va 2624054
refactor: move collecton/enqueued to the test runner
sheremet-va ef9a086
refactor: remove test.skipped()
sheremet-va 10f3890
fix: correct skipped state
sheremet-va ebf3454
docs: cleanup
sheremet-va 5d2bd70
docs: remove skipped from suite methods
sheremet-va cd291db
feat: add onTestModuleCollected
sheremet-va 0ef6608
refactor: add events to TaskResultPack
sheremet-va d515785
docs: update result() docs
sheremet-va 87d313b
docs: add state() docs
sheremet-va 934087b
docs: fix result description
sheremet-va 6567412
docs: update metadata docs
sheremet-va 5e3b7cb
refactor: add event
sheremet-va 20696a5
chore: fix ts error
sheremet-va ed1332e
fix: set event in typechecking
sheremet-va 89baf8e
refactor: move log to test run
sheremet-va 4afce13
refactor: move onFinished
sheremet-va 4557b4b
fix: report skipped tests of suites
AriPerkkio 3e0990e
Merge remote-tracking branch 'upstream/main' into feat/new-reporter-api
AriPerkkio 1a74b1b
feat(reporter): `'dot'` to use new reporter API
AriPerkkio 84ddc2f
refactor: mark readonly properties
sheremet-va 1f03389
refactor: rename spec.module to spec.testModule
sheremet-va 19fd301
docs: update options type, remove "reporter api" warning
sheremet-va be5b429
feat(reporter): summary to use new reporter API, except before & afte…
AriPerkkio 02c0279
refactor: add comments and clarifications
sheremet-va 1c8fb37
chore: cleanup
sheremet-va f6c3571
refactor: remove `TaskParser`, use new reporter API completely
AriPerkkio eb36354
refactor: rename new APIs
AriPerkkio 0cef2b5
fix: resolve reporter life cycle from `onTaskUpdate` event field
AriPerkkio b5b962f
fix: report hooks only when they actually exist
AriPerkkio dd6ebc5
chore: add some test run docs and make arrays readonly
sheremet-va 44ad507
docs: fix link
sheremet-va 23730ae
Merge branch 'main' of github.com:vitest-dev/vitest into feat/new-rep…
sheremet-va c62f22b
refactor: add more docs, export TestRunEndReason and SerializedError
sheremet-va File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Test Lifecycle | ||
|
||
<!-- TODO: lifecyle diagram and reporter API --> | ||
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import type { TaskResultPack } from '@vitest/runner' | ||
import type { Vitest } from './core' | ||
import type { TestModule } from './reporters/reported-tasks' | ||
import type { TestSpecification } from './spec' | ||
|
||
export class TestRun { | ||
AriPerkkio marked this conversation as resolved.
Show resolved
Hide resolved
|
||
private tests = emptyCounters() | ||
private suites = emptyCounters() | ||
|
||
constructor(private vitest: Vitest) {} | ||
|
||
async start(specifications: TestSpecification[]) { | ||
this.tests = emptyCounters() | ||
this.suites = emptyCounters() | ||
this.suites.total = specifications.length | ||
await this.vitest.report('onTestRunStart', specifications) | ||
} | ||
|
||
enqueued(module: TestModule) { | ||
// TODO | ||
} | ||
|
||
collected(modules: TestModule[]) { | ||
// TODO | ||
} | ||
|
||
updated(update: TaskResultPack[]) { | ||
// TODO | ||
} | ||
|
||
async end() { | ||
// TODO | ||
await this.vitest.report('onTestRunEnd', [], [], 'passed') | ||
} | ||
} | ||
|
||
interface Counter { | ||
total: number | ||
completed: number | ||
passed: number | ||
failed: number | ||
skipped: number | ||
todo: number | ||
} | ||
|
||
function emptyCounters(): Counter { | ||
return { completed: 0, passed: 0, failed: 0, skipped: 0, todo: 0, total: 0 } | ||
} |
This file contains 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
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we use
vitepress-plugin-mermaid
for this? 🤔https://emersonbottero.github.io/vitepress-plugin-mermaid/guide/styles.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe when the lifecycle is finalised