Skip to content
New issue

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

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

Already on GitHub? # to your account

Not able to run test cases in react + vite #2112

Open
nikhilguptagl opened this issue Mar 2, 2024 · 2 comments
Open

Not able to run test cases in react + vite #2112

nikhilguptagl opened this issue Mar 2, 2024 · 2 comments
Labels
backlog Queued in backlog bug Something isn't working

Comments

@nikhilguptagl
Copy link

While running test cases, I am getting below errors -

src/shared/components/BpmnEditor/tests/BpmnEditor.test.tsx [ src/shared/components/BpmnEditor/tests/BpmnEditor.test.tsx ]
SyntaxError: Unexpected token 'export'
❯ Object.compileFunction node:vm:352:18
❯ Object. node_modules/bpmn-js-properties-panel/lib/cmd/UpdateBusinessObjectHandler.js:4:10

Module D:/Repository/Hitachi/content-hub-ui/Frontend/author/node_modules/bpmn-js/lib/util/ModelUtil.js:9 seems to be an
ES Module but shipped in a CommonJS package. You might want to create an issue to the package "bpmn-js" asking them to ship the file in .mjs extension or add "type": "module" in their package.json.

As a temporary workaround you can try to inline the package by updating your config:

// vitest.config.js
export default {
  test: {
    server: {
      deps: {
        inline: [
          "bpmn-js"
        ]
      }
    }
  }
}

However, I am also adding bpmn-js in vite.config but still it throws the same error. Is there anything I can do to run my test cases sucessfully or the team needs to add "type": "module" in their package.json ?

@nikhilguptagl nikhilguptagl added the bug Something isn't working label Mar 2, 2024
@nikku
Copy link
Member

nikku commented Mar 4, 2024

Is there anything I can do to run my test cases sucessfully or the team needs to add "type": "module" in their package.json ?

The team (we) need to convert this library to ESM in order to fix this issue.

@nikku nikku added the backlog Queued in backlog label Mar 4, 2024
@nikku
Copy link
Member

nikku commented Mar 4, 2024

Even with this issue addressed you'd likely still run into issues testing bpmn-js in node. Consider to mock it or apply browser-based testing (including bundling).

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

No branches or pull requests

2 participants