testify icon indicating copy to clipboard operation
testify copied to clipboard

Monorepo support

Open calebboyd opened this issue 5 years ago • 6 comments

Neat plugin, running tests from codelens is super useful! -- Maybe this is already possible, but I'm not sure how

Is your feature request related to a problem? Please describe.

Test runner not detected in monorepo

For example

project
 - modules
   - moduleA
     - node_modules
     - testA.spec.ts
   - moduleB
     - node_modules
     - testB.spec.ts

Describe the solution you'd like

I'd like to use run testA.spec.ts with a test runner from moduleA/node_modules

calebboyd avatar Aug 16 '20 12:08 calebboyd

Hello @calebboyd !

This feature would really be a great addition to the project. The way it works today is:

  • the extension looks for the test ruuner in the node_modules directory in the root of the workspace; or
  • the extension looks for the test ruuner at the path you specified in the configurations;

I am trying to figure out a new method write a factory for this so it can be a little more flexible but couldn't find a way yet. I'll make this issue with help wanted

felixjb avatar Aug 19 '20 14:08 felixjb

Hey @felixjb I'm looking into this a bit and am working on the following approach

(pseudo code)

const { runnerHints, testNames } = parse(testFile)
const runner = findRunnerUp(testFile, runnerHints)
const testRoot = findPkgUp(testFile, runner.name)
runner.runTest({ cwd: testRoot, testFile, testNames })

The big difference being, the cwd of the runner command is set to the nearest package.json directory to the test file, that contains that runner. I can also work on moving runner command generation to a factory function and generalize the runTest,debugTest implementation.

calebboyd avatar Apr 27 '21 23:04 calebboyd

Hey @calebboyd , thank you for picking this up.

That package.json idea is pretty cool. Maybe you could also base your implementation on how Git handles the commits in a repository, which seems similar

felixjb avatar May 01 '21 18:05 felixjb

Should this not work out of the box when using workspaces?

roggenbrot avatar Jun 18 '21 07:06 roggenbrot

@roggenbrot I don't know, maybe not. Some projects use a monorepo structure, some even use a framework called lerna which makes one repo have multiple package.json files

felixjb avatar Jun 23 '21 14:06 felixjb