Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
NickHeiner opened this issue Feb 22, 2021 · 3 comments
Open

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

NickHeiner opened this issue Feb 22, 2021 · 3 comments
Labels
bug Something isn't working

Comments

@NickHeiner
Copy link

NickHeiner commented Feb 22, 2021

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.

@rwjblue
Copy link
Owner

rwjblue commented Feb 22, 2021

/Users/nheiner/code/tvui/transforms/hoist-require

Is that path listed correct? What is the actual path?

@rwjblue
Copy link
Owner

rwjblue commented Feb 22, 2021

We might need to add a workingDir type option, so runTransformTest knows how to find the transform itself.

@rwjblue rwjblue added the bug Something isn't working label Feb 22, 2021
@NickHeiner
Copy link
Author

Good call. The right path is /Users/nheiner/code/tvui/tools/codemod-2/transforms/hoist-require.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants