Skip to content

vue: add jest testing hints on imports#2568

Open
lucas-koehler wants to merge 3 commits intomasterfrom
lk/2250-vue-test-import-order-doc
Open

vue: add jest testing hints on imports#2568
lucas-koehler wants to merge 3 commits intomasterfrom
lk/2250-vue-test-import-order-doc

Conversation

@lucas-koehler
Copy link
Copy Markdown
Contributor

@lucas-koehler lucas-koehler commented Apr 16, 2026

  • Add documentation on import order for jest (or other) unit tests using CJS transformations
  • Add explicit exports property to vue's package.json to facilitate tools finding the correct bundle

Closes #2250

- Add documentation on import order for jest (or other) unit tests using CJS transformations
- Add explicit `exports` property to vue's package.json to facilitate tools finding the correct bundle

Mitigates #2250
@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 16, 2026

Deploy Preview for jsonforms-examples ready!

Name Link
🔨 Latest commit b072bf9
🔍 Latest deploy log https://app.netlify.com/projects/jsonforms-examples/deploys/69f882c537b7a000089a1ea7
😎 Deploy Preview https://deploy-preview-2568--jsonforms-examples.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coveralls
Copy link
Copy Markdown

coveralls commented Apr 16, 2026

Coverage Status

coverage: 82.957%. remained the same — lk/2250-vue-test-import-order-doc into master

@lucas-koehler
Copy link
Copy Markdown
Contributor Author

lucas-koehler commented Apr 16, 2026

The "exports" seems to have caused test issues on windows and mac 😅

Reason:
The exports field is strict and relies on accurate realpath() resolution to determine package identity and resolve relative entry points. In a pnpm workspace monorepo, where packages are symlinked (or junction-linked on Windows), this resolution has subtle cross-platform differences that can cause the exports map to either fail entirely or resolve to the wrong bundle format — while the more lenient main/module fallback works reliably on all platforms.

This is a known category of issue in the Node.js ecosystem — exports + workspace symlinks + cross-platform is a notorious combination. Removing the exports field was the pragmatic fix.

@lucas-koehler lucas-koehler changed the title vue: add jest testing hints on imports and add exports to package.json vue: add jest testing hints on imports Apr 29, 2026
Comment thread packages/vue/README.md Outdated
Comment on lines +303 to +305
```ts
// May cause errors in tests:
// "Property 'controlWrapper' was accessed during render but is not defined on instance"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The quoted error references controlWrapper, which comes from the Vuetify bindings. The generic Vue README does not seem like the correct place for this.

Comment thread packages/vue/README.md Outdated
### Testing with Jest / Vitest

When testing custom renderers with Jest or Vitest using CJS transforms, `vue` must be imported **before** `@jsonforms/vue` in your renderer files.
This is due to the CJS bundle eagerly evaluating Vue component definitions at `require()` time, which can cause issues when Jest's module resolution processes imports sequentially.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit generic. The cause seems to be that we call defineComponent at module load so vue needs to be initialized first. Do other component libraries have the same issue?

@lucas-koehler
Copy link
Copy Markdown
Contributor Author

@sdirix I made the wording a bit more precise and also added a note to the vue-vuetify and vue-vanilla readmes referencing the vue readme.
IMO this should be sufficient for now and we can add more information later if necessary.

@lucas-koehler lucas-koehler requested a review from sdirix May 4, 2026 11:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Jest tests depend on order of imports for defineComponent

3 participants