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

chore: add test with Jest and ESM bundle [POC] #96

Closed
wants to merge 40 commits into from
Closed

Conversation

csouchet
Copy link
Member

@csouchet csouchet commented Aug 30, 2023

Missing the ESM bundle for bpmn-visualization: process-analytics/bpmn-visualization-js#2840

Covers #65.

tbouffard and others added 30 commits August 30, 2023 17:05
# Conflicts:
#	package-lock.json
version 0.27.0. Missed some API of the latest version
…n/dist/bpmn-visualization.esm.js' as moduleNameMapper
…feature of the JavaScript language. Avoid relying on their current behavior and syntax as those might change in a future version of Node.js.

(Use `node --trace-warnings ...` to show where the warning was created)
(node:22343) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time
TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at pathsToModuleNameMapper (/Users/csouchet/Source/Process Analytics/bv-experimental-add-ons/node_modules/ts-jest/dist/config/paths-to-module-name-mapper.js:28:39)
    at file:///Users/csouchet/Source/Process%20Analytics/bv-experimental-add-ons/packages/addons/jest.config.mjs:87:21
    at ModuleJob.run (node:internal/modules/esm/module_job:194:25)
    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/csouchet/Source/Process Analytics/bv-experimental-add-ons/packages/addons/__tests__/plugins-support.test.ts:17
    import { expect, test } from '@jest/globals';
    ^^^^^^

    SyntaxError: Cannot use import statement outside a module
      at Runtime.loadEsmModule (../../node_modules/jest-runtime/build/index.js:516:20)
@csouchet csouchet added the chore Build, CI/CD or repository tasks (issues/PR maintenance, environments, ...) label Aug 30, 2023
@sonarcloud
Copy link

sonarcloud bot commented Aug 30, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 5 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@tbouffard tbouffard marked this pull request as draft August 30, 2023 17:03
@tbouffard
Copy link
Member

Put in draft, as this is a POC as #95

@tbouffard tbouffard changed the title chore: add test with Jest and ESM bundle chore: add test with Jest and ESM bundle [POC] Aug 31, 2023
@csouchet csouchet closed this Aug 31, 2023
@csouchet csouchet deleted the jest_esm branch August 31, 2023 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Build, CI/CD or repository tasks (issues/PR maintenance, environments, ...)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants