Skip to content

Running generated test.js via Jest doesn't work in a monorepo #160

@NickHeiner

Description

@NickHeiner

Version: 3.1.2.

When I run jest transforms/my-transform/test.js in a standalone repo, it works.

When I run it in a monorepo, I get this error:

 FAIL  tools/codemod-2/transforms/hoist-require/test.js
  ● Test suite failed to run

    Cannot find module '/Users/nheiner/code/tvui/transforms/hoist-require' from 'node_modules/codemod-cli/src/transform-support.js'

      3 | const { runTransformTest } = require('codemod-cli');
      4 |
    > 5 | runTransformTest({
        | ^
      6 |   name: 'hoist-require',
      7 | });

      at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:306:11)
      at getTransformPath (node_modules/codemod-cli/src/transform-support.js:6:18)
      at transformDetails (node_modules/codemod-cli/src/test-support/utils.js:7:23)
      at runTransformTest (node_modules/codemod-cli/src/test-support.js:63:17)
      at Object.runTransformTest (tools/codemod-2/transforms/hoist-require/test.js:5:1)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        1.566 s
Ran all test suites matching /tools\/codemod-2\/transforms\/hoist-require\/test.js/i.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

In the monorepo, when I run the generated test.js via codemod-cli test, it works.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions