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

Jest is broken #15165

Closed
alper opened this issue Jul 5, 2024 · 4 comments
Closed

Jest is broken #15165

alper opened this issue Jul 5, 2024 · 4 comments
Labels
Needs Reproduction Every bug report requires a minimal reproduction

Comments

@alper
Copy link

alper commented Jul 5, 2024

Version

29

Steps to reproduce

Jest is giving me:

 FAIL  src/handlers/restapi/__tests__/redirect.test.ts
  ● Test suite failed to run

    Jest encountered an unexpected token

    Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.

    Out of the box Jest supports Babel, which will be used to transform your files into valid JS based on your Babel configuration.

    By default "node_modules" folder is ignored by transformers.

    Here's what you can do:
     • If you are trying to use ECMAScript Modules, see https://jestjs.io/docs/ecmascript-modules for how to enable it.
     • If you are trying to use TypeScript, see https://jestjs.io/docs/getting-started#using-typescript
     • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
     • If you need a custom transformation specify a "transform" option in your config.
     • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

    You'll find more details and examples of these config options in the docs:
    https://jestjs.io/docs/configuration
    For information about custom transformations, see:
    https://jestjs.io/docs/code-transformation

    Details:

    /Users/alper/Code/backend/move-token-registry/spaces/erp/node_modules/.pnpm/[email protected]/node_modules/axios/index.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){import axios from './lib/axios.js';
                                                                                      ^^^^^^

    SyntaxError: Cannot use import statement outside a module

      at Runtime.createScriptFromCode (../../node_modules/.pnpm/[email protected]/node_modules/jest-runtime/build/index.js:1728:14)
      at Object.<anonymous> (../../node_modules/.pnpm/[email protected]/node_modules/intuit-oauth/src/OAuthClient.js:30:15)

Expected behavior

I expect it to run.

Actual behavior

It fails.

Additional context

No response

Environment

System:
    OS: macOS 14.4.1
    CPU: (10) arm64 Apple M2 Pro
  Binaries:
    Node: 18.6.0 - ~/.nvm/versions/node/v18.6.0/bin/node
    Yarn: 1.22.21 - ~/Library/pnpm/yarn
    npm: 8.13.2 - ~/.nvm/versions/node/v18.6.0/bin/npm
    pnpm: 8.8.0 - ~/Library/pnpm/pnpm
    bun: 1.1.18 - /opt/homebrew/bin/bun
@SimenB
Copy link
Member

SimenB commented Jul 5, 2024

Did you try any of the suggestions in the error message? Regardless, this is without a reproduction

@SimenB SimenB added Needs Reproduction Every bug report requires a minimal reproduction and removed Needs Triage Bug Report labels Jul 5, 2024
Copy link

github-actions bot commented Jul 5, 2024

As noted in the Bug Report template, all bug reports requires a minimal reproduction. Please open up a new issue providing one. Read more at https://stackoverflow.com/help/minimal-reproducible-example.

@github-actions github-actions bot closed this as completed Jul 5, 2024
@alper
Copy link
Author

alper commented Jul 9, 2024

We worked our way around it in some way but maybe it would be better if typescript support was just not a part of Jest? It obviously does not really work.

Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Needs Reproduction Every bug report requires a minimal reproduction
Projects
None yet
Development

No branches or pull requests

2 participants