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

[Bug]: Jest encountered an unexpected token 'export' with "uuid" module #12790

Closed
zak39 opened this issue May 2, 2022 · 3 comments
Closed

[Bug]: Jest encountered an unexpected token 'export' with "uuid" module #12790

zak39 opened this issue May 2, 2022 · 3 comments

Comments

@zak39
Copy link

zak39 commented May 2, 2022

Version

28.0.2

Steps to reproduce

These steps to produce my issue :

  1. Clone my repo at https://github.com/arawa/workspace.git
  2. Change the branch for dependabot/npm_and_yarn/jest-28.0.3 git checkout dependabot/npm_and_yarn/jest-28.0.3 (link to Dependabot's PR : npm: bump jest from 27.5.1 to 28.0.3 arawa/workspace#483 )
  3. Build the project with the make command (you must have npm 7.X and node 14.X)
  4. Install jest-environment-jsdom : npm -i --save-dev jest-environment-jsdom
  5. Then, execute the npm test

Expected behavior

I expect to see all tests passed to green.

Actual behavior

I get this error message after run npm test.

npm test

> workspace@1.0.0 test
> jest

 PASS  src/tests/unit/spaceService.test.js
  convertGroupfolderToSpace method
    ✓ Return object type (9 ms)
    ✓ Is not undefined (1 ms)

  console.warn
    Proxying an event bus of version 1.3.0 with 2.1.1

      at new warn (node_modules/@nextcloud/vue/node_modules/@nextcloud/event-bus/lib/ProxyBus.ts:17:21)
      at getBus (node_modules/@nextcloud/vue/node_modules/@nextcloud/event-bus/lib/index.ts:20:16)
      at Object.getBus (node_modules/@nextcloud/vue/node_modules/@nextcloud/event-bus/lib/index.ts:26:13)

 PASS  src/tests/unit/store.test.js
  Vuex store tests
    ✓ Adds a space in the Vuex store (4 ms)
    ✓ Adds a group to the space (1 ms)
    ✓ Removes a group to the space
    ✓ Sets space quota (1 ms)
    ✓ Get space quota (1 ms)
    ✓ Adds a user to the space (7 ms)
    ✓ Count users in workspace (2 ms)
    ✓ Count users in group
    ✓ Removes a user from the space

  console.warn
    Proxying an event bus of version 1.3.0 with 2.1.1

      at new warn (node_modules/@nextcloud/vue/node_modules/@nextcloud/event-bus/lib/ProxyBus.ts:17:21)
      at getBus (node_modules/@nextcloud/vue/node_modules/@nextcloud/event-bus/lib/index.ts:20:16)
      at Object.getBus (node_modules/@nextcloud/vue/node_modules/@nextcloud/event-bus/lib/index.ts:26:13)

 FAIL  src/tests/unit/selectUsers.test.js
  ● 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:

    /home/zak/Documents/arawa/codes/workspace/node_modules/uuid/dist/esm-browser/index.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){export { default as v1 } from './v1.js';
                                                                                      ^^^^^^

    SyntaxError: Unexpected token 'export'

      at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1773:14)
      at node_modules/@nextcloud/calendar-js/dist/index.umd.js:2:102
      at Object.<anonymous> (node_modules/@nextcloud/calendar-js/dist/index.umd.js:5:3)

 FAIL  src/tests/unit/home.test.js
  ● 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:

    /home/zak/Documents/arawa/codes/workspace/node_modules/uuid/dist/esm-browser/index.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){export { default as v1 } from './v1.js';
                                                                                      ^^^^^^

    SyntaxError: Unexpected token 'export'

      at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1773:14)
      at node_modules/@nextcloud/calendar-js/dist/index.umd.js:2:102
      at Object.<anonymous> (node_modules/@nextcloud/calendar-js/dist/index.umd.js:5:3)

Test Suites: 2 failed, 2 passed, 4 total
Tests:       11 passed, 11 total
Snapshots:   0 total
Time:        5.269 s
Ran all test suites.

Additional context

No response

Environment

System:
    OS: Linux 5.4 Ubuntu 20.04.4 LTS (Focal Fossa)
    CPU: (8) x64 Intel(R) Core(TM) i5-8250U CPU @ 1.60GHz
  Binaries:
    Node: 14.19.1 - /usr/bin/node
    Yarn: 1.22.10 - /usr/bin/yarn
    npm: 7.24.2 - /usr/bin/npm
  npmPackages:
    jest: ^28.0.2 => 28.0.2
@SimenB
Copy link
Member

SimenB commented May 2, 2022

Duplicate of #12770

@zak39
Copy link
Author

zak39 commented May 2, 2022

Duplicate of #12770

Thanks @SimenB :)

I'm sorry, I didn't find this issue to fix my problem...

Thank you again ! ☺️

zak39 added a commit to arawa/workspace that referenced this issue May 2, 2022
With Jest 28, it doesn't into account the 'uuid' module.

I resolved this issue creating a new bug issue to Jest : jestjs/jest#12790

But, it's a duplicate of this issue uuidjs/uuid#616

Resolve with this suggestion : uuidjs/uuid#616 (comment)
zak39 added a commit to arawa/workspace that referenced this issue May 2, 2022
With Jest 28, it doesn't into account the 'uuid' module.

I resolved this issue creating a new bug issue to Jest : jestjs/jest#12790

But, it's a duplicate of this issue uuidjs/uuid#616

Resolve with this suggestion : uuidjs/uuid#616 (comment)
@github-actions
Copy link

github-actions bot commented Jun 2, 2022

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 Jun 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants