soywod / react-pin-field

📟 React component for entering PIN codes.
https://soywod.github.io/react-pin-field/
MIT License
412 stars 24 forks source link

[bug] Test crashes with Jest #46

Closed jolic closed 2 years ago

jolic commented 3 years ago

I'm using craco and the tests of the app works until I added react-pin-field:

` SyntaxError: Unexpected token 'export'

  at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1350:14)
  at Object.<anonymous> (node_modules/react-pin-field/dist/react-pin-field.cjs.development.js:6:16)

`

How to solve this?

soywod commented 3 years ago

Which version do you use?

jolic commented 3 years ago

I'm using 2.0.0-beta.2

jolic commented 3 years ago

I'm now using another package.

jmargolisvt commented 3 years ago

it should pass without any problem.

Except that it doesn't. I am also using 2.0.0-beta.2. Does that count as greater than or less than 2.0.0 here? I am getting the same error as the OP. Downgraded to 1.1.0, tests are passing.

soywod commented 3 years ago

I'm using craco and the tests of the app works until I added react-pin-field:

  at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1350:14)
  at Object.<anonymous> (node_modules/react-pin-field/dist/react-pin-field.cjs.development.js:6:16)

If I follow the error, it fails on this line:

var pinField = require('@soywod/pin-field');

Did you install @soywod/pin-field? Since the v2.0.0-beta.0, react-pin-field depends on it so it needs to be installed (see the CHANGELOG).

jmargolisvt commented 3 years ago

I did install it. I still get: SyntaxError: Unexpected token 'export'

soywod commented 3 years ago

Hm. It's really strange, because node_modules/react-pin-field/dist/react-pin-field.cjs.development.js does not contain any export (since it is a CJS build), so how come you get SyntaxError: Unexpected token 'export'? Could you try to set up a repo that reproduces this bug (so I can investigate a bit more)?

soywod commented 2 years ago

The native web component was a big mistake, it led to so many issues… I ended up rolling back to v1 state, without web component (pure React implementation). The issue should be fixed starting from the v3.0.11.