dd-trace-js icon indicating copy to clipboard operation
dd-trace-js copied to clipboard

vitest support for CI

Open nertzy opened this issue 3 years ago • 5 comments

vitest is a new test framework similar to Jest that runs on top of Vite.

It would be great if dd-trace-js could instrument vitest similar to how the Jest integration works.

nertzy avatar Sep 12 '22 19:09 nertzy

+1 on the request please.

andrei-ivanov-pie avatar Jan 12 '23 18:01 andrei-ivanov-pie

👍 on this one

paulvidal avatar May 12 '23 14:05 paulvidal

🙏

tainmar avatar Jul 04 '23 14:07 tainmar

:+1: vitest is gaining more and more traction as a replacement of jest. We recently-ish had to switch away from jest because of performance issues and vitest was the easiest/simplest switch. Now that we're starting to look into datadog CI integration, I really wished there was native support for vitest

Cellule avatar Nov 09 '23 20:11 Cellule

Today I was wondering "why did my tests stop showing up in Datadog" and I realized it is because I haven't published a repo that uses jest in several weeks. All my most recent code is using vitest. It is basically a must for the Vue framework and the support for module syntax is superior. And performance. So fast

I am an every day Datadog user. This will not stop me from using Datadog but I will not be able to make full use of CI. Using vitest is more necessary to my workflow than seeing it in Datadog

nullfame avatar Jan 12 '24 18:01 nullfame

adding another comment here to request support. is there any traction on this front that can be surfaced here?

opeologist avatar Jun 18 '24 16:06 opeologist

hi everyone! Good news: this is currently being worked on in https://github.com/DataDog/dd-trace-js/pull/4415. It's still going to take a bit but vitest support is coming 😄

juan-fernandez avatar Jun 20 '24 14:06 juan-fernandez

🎉 🚢 vitest support is now released in

  • https://github.com/DataDog/dd-trace-js/releases/tag/v5.18.0
  • https://github.com/DataDog/dd-trace-js/releases/tag/v4.42.0

juan-fernandez avatar Jul 11 '24 15:07 juan-fernandez

until we update the docs with the instructions, here's how you can try the vitest integration:

npm install --save-dev dd-trace

Make sure the dd-trace installed version is >=5.18.0 or >=4.42.0.

Then run your vitest tests passing NODE_OPTIONS='--import dd-trace/register.js -r dd-trace/ci/init'.

⚠️ Important:

  • It needs an extra parameter when compared to running tests with mocha, jest or other supported test frameworks: --import dd-trace/register.js
  • The minimum supported Node.js versions are >=18.19 and >=20.6

For example, if your package.json looks like:

"scripts": {
  "test": "vitest run"
}

Run

NODE_OPTIONS='--import dd-trace/register.js -r dd-trace/ci/init' DD_SERVICE=your-javascript-app-tests npm run test 

Take into account that you'll still need an API key or a running agent (see docs for more info)

juan-fernandez avatar Jul 12 '24 10:07 juan-fernandez