unjs / std-env

Runtime Agnostic JS utils
MIT License
459 stars 25 forks source link

Add detection for tests runners ? (Jest, Vitest, Playwright, etc...) #124

Open IonianPlayboy opened 6 months ago

IonianPlayboy commented 6 months ago

Describe the feature

Most test framework sets a couple of env variables that we could use to detect them.

We could have a similar API here to the provider detection :

import { isTest, testRunner, testRunnerInfo } from "std-env";

console.log({
  isCI, // true
  provider, // "vitest"
  providerInfo, // { name: "vitest", isTest: true, ...etc }
});

Additional information