-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Expose internal events for custom reporters via config #3247
Expose internal events for custom reporters via config #3247
Conversation
I agree that this is the easiest approach that can ship. I don't want to provide any SemVer guarantees to the internal event objects though. This should be an experiment requiring opt-in through the configuration (
Shared workers survive across multiple test runs (when in watch mode) and so would be appropriate. It's just awkward that you have to launch them from a test worker and they could integrate better with the concept of a test run. |
6930749
to
78f9d37
Compare
lib/api-event-iterator.js
Outdated
import {on} from 'node:events'; | ||
|
||
export async function * asyncEventIteratorFromApi(api) { | ||
for await (const [plan] of on(api, 'run')) { |
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.
is there a scenario where api
will emit run
multiple times? (other than watch mode maybe?)
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.
No, just in watch mode. May be helpful for the callback function to know that watch mode is active though.
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.
👍 might be good to add as a future enhancement
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.
apologies for the late replies!
happy to add more tests, but not sure what to look for
Sorry @codetheweb I've had very little time for open source lately. |
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.
This is looking pretty good, I've added some suggestions. A ton of care went into typing the state change events!
When it comes to additional testing, the good news is that for these "experimental" features the bar is a little lower, so this is pretty close to done IMHO.
lib/api-event-iterator.js
Outdated
import {on} from 'node:events'; | ||
|
||
export async function * asyncEventIteratorFromApi(api) { | ||
for await (const [plan] of on(api, 'run')) { |
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.
No, just in watch mode. May be helpful for the callback function to know that watch mode is active though.
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.
Looking good, bar the failing tests :)
ec70158
to
a9eac47
Compare
types/state-change-events.d.cts
Outdated
source: ErrorSource | undefined; | ||
}; | ||
|
||
// eslint-disable-next-line @typescript-eslint/naming-convention |
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.
a new rule started complaining about this, ava is always stylized AVA so I think it's ok to disable here?
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.
I'd like to stick with the rule here. Will push up a commit.
We've been using a similar approach to this internally on a patched version of AVA for the last few weeks to pipe test runs to Datadog and it's been working great.
Alternatives:
This is very much still a draft, just wanted to get some initial feedback on whether this solution is ok before I continue down the path. Still need to:
import type {AVAEvent} from "ava/internal"
or something?)