isbot: Not compatible with jest version 28

Steps to reproduce

import isbot from 'isbot' anywhere in a file that’s tested. install and use jest@28 to test the file.

Expected behaviour

The isbot import should work.

Actual behaviour

Jest throws an error about unexpected token inside isbot.

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/marklyck/colony/colony-frontend/node_modules/.pnpm/isbot@3.4.6/node_modules/isbot/index.mjs:328
    export { isbot as default };
    ^^^^^^

    SyntaxError: Unexpected token 'export'

      1 | import LogRocket from 'logrocket'
    > 2 | import isbot from 'isbot'
        | ^

Additional details

Jest@28 started supporting exports in package.json; https://jestjs.io/docs/upgrading-to-jest28#packagejson-exports

This is why this breaks, and it suggests submitting an issue to isbot to fix the exports in this package to be correct.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 2
  • Comments: 15 (9 by maintainers)

Most upvoted comments

Resolved in version 3.5.0

@wadehammes Good news, Once I’ve defined jest environment as jsdom - I was able to replicate your issue.

If you could please test the next version using “next” tag - we can see that it solved the issue for you and release a stable version:

npm i isbot@next

This helped me: https://stackoverflow.com/questions/60714101/how-to-setup-jest-with-node-modules-that-use-es6

Adding transformIgnorePatterns: ["<rootDir>/node_modules/(?!isbot)"], to my custom Jest config allowed tests to pass with Jest 28:

image

Thank you for opening an issue, Mark. I will investigate today