"executor": "@nx/vite:test" doesn't create coverage when running from `nx affected`

59 Views Asked by At

We have a monorepo with yarn workspaces that uses nx to manage targets (=package.json scripts) and it runs jest by default for test target (defined with jest plugin in targetDefaults)

However, in 1 project we use vitest and I've changed the target to use @nx/vite:test with relevant configuration:

"test": {
      "executor": "@nx/vite:test",
      "outputs": ["{projectRoot}/coverage"],
      "options": {
        "configFile": "{projectRoot}/vite.config.ts",
        "reportsDirectory": "{projectRoot}/coverage"
      },
      "cache": true
    },

All of this is exactly according to the nx documentation[https://nx.dev/nx-api/vite/executors/test].

When running the target (test) in the project directory, it works and creates the coverage folder as output, but when running from root folder with nx affected --target-test it doesn't produce the coverage directory although it hits the correct target.

I've verified the specific project nx configuration using yarn nx show project myVitestProj.

Did anyone encounter this? Couldn't find any hint in Github issues and nx Discord.

0

There are 0 best solutions below