Skip to content

Instrument spawned processes with ts-node #2911

Answered by AriPerkkio
kirinnee asked this question in Q&A
Discussion options

You must be logged in to vote

Can Vitest instrument ts-node subprocesses spawned by spawn or exec?

Currently Vitest does not intercept require() calls that ts-node hooks into. It should be possible to implement a require hook for Istanbul instrumentation so that code that is not run through vite-node could be included in code coverage.

But I'm not sure if it can "see" processes launched by child_process.spawn. There's nothing about patching child_process here: https://github.com/istanbuljs/istanbuljs/blob/fb8cb4bb99c9e5d36c8b011338d2ab5d3c72ff9c/packages/istanbul-lib-hook/lib/hook.js#L229-L236
Could you provide small example of this so that I could test it?

Replies: 1 comment 9 replies

Comment options

You must be logged in to vote
9 replies
@AriPerkkio
Comment options

@kirinnee
Comment options

@AriPerkkio
Comment options

@DenizUgur
Comment options

@AriPerkkio
Comment options

Answer selected by kirinnee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants