firsttris / vscode-jest-runner

Simple way to run or debug one or more tests from context menu, codelens or command plalette
https://marketplace.visualstudio.com/items?itemName=firsttris.vscode-jest-runner
MIT License
265 stars 124 forks source link

Version 0.4.54 is broken for projects with multiple jest configs (monorepos) #268

Closed CarltonHowell closed 2 years ago

CarltonHowell commented 2 years ago

Problem

Version 0.4.54 is broken. Clicking the run button does nothing, no jest tests are triggered.

Solution

Downgrading to version 0.4.53 fixes the issue.

firsttris commented 2 years ago

mhh could not reproduce this, for me it still works?

CarltonHowell commented 2 years ago

I'm running this in a monorepo using rushjs.

This change is what stopped it working: https://github.com/firsttris/vscode-jest-runner/commit/ea229521ca7a83f29d3e9bd1169f1d73fc1d1e90

A monorepo doesn't have a package.json file in the root directory but instead has multiple within each nested app/lib.

firsttris commented 2 years ago

can you elaborate, how it worked for you before this commit?

where did you packages get the jest config from.

CarltonHowell commented 2 years ago

The only settings I needed were:

"jestrunner.codeLensSelector": "**/*.{test,spec}.{js,jsx,ts,tsx}",
"jestrunner.jestCommand": "node_modules/.bin/jest",

Other than that it would work in any test file in each app/lib.

CarltonHowell commented 2 years ago

The run/debug button still show up in my tests, but clicking does nothing. The terminal does not show any attempt at running the tests even

CarltonHowell commented 2 years ago

In the monorepo each app/lib using a single jest config which is compiled into node_modules/.bin/jest. Each app/lib contains this:

A typical monorepo project can look like:

apps/
    app-1/
      - index.js
      - package.json
      ...
      node_modules/
      .bin
        - jest
        ...
      ...
  app-2/
      - index.js
      - package.json
      ...
      node_modules/
      .bin
        - jest
        ...
      ...

libs/
    lib-1/
      - index.js
      - package.json
      ...
      node_modules/
      .bin
        - jest
        ...
      ...
  lib-2/
      - index.js
      - package.json
      ...
      node_modules/
      .bin
        - jest
        ...
      ...
...
CarltonHowell commented 2 years ago

With this latest version update...

firsttris commented 2 years ago

and the jest config where is it? inside those package.json`s?

CarltonHowell commented 2 years ago

each app/lib has a jest.config.json

 app-1/
      - index.js
      - package.json
      - jest.config.json
      ...
      node_modules/
      .bin
        - jest
        ...
      ...
firsttris commented 2 years ago

okay, i reverted this change, next version will be online soon

CarltonHowell commented 2 years ago

Much appreciated @firsttris !

CarltonHowell commented 2 years ago

Confirming that the revert 0.4.55 has fixed the problem and it's back to working in monorepos. @firsttris Cheers!