Skip to content

[WTF-2710]: Fix unit tests failing on ValueStatus import#191

Open
alihcsumer wants to merge 6 commits into
masterfrom
wtf/fixunittestimports
Open

[WTF-2710]: Fix unit tests failing on ValueStatus import#191
alihcsumer wants to merge 6 commits into
masterfrom
wtf/fixunittestimports

Conversation

@alihcsumer

Copy link
Copy Markdown
Contributor

Checklist

  • Contains unit tests ❌
  • Contains breaking changes ❌
  • Did you update version and changelog? ❌

This PR contains

  • Bug fix

What is the purpose of this PR?

...

Relevant changes

Unit tests run via pluggable-widgets-tools test:unit:web fail to load any test suite whose module graph imports a runtime value from the mendix package.
The suite errors out before any test runs with "This package should not be used in the runtime."

@alihcsumer alihcsumer requested a review from a team as a code owner July 6, 2026 08:35
@weirdwater weirdwater changed the title [WTF-2710] Fix unit tests failing on ValueStatus import [WTF-2710]: Fix unit tests failing on ValueStatus import Jul 6, 2026
@weirdwater

Copy link
Copy Markdown
Collaborator

I like the approach proposed in !192 better, since it follows a pattern we already use for mocking other parts of the mendix package.

Additionally I would ask to add some form of type checking. In this example the mocked enum is checked for completeness. This will throw an error when the mock misses a member.

export const FormatterType: { [t in keyof typeof mendix.FormatterType]: string } = {
    Number: "number",
    DateTime: "datetime",
}

I tried to check for both completeness and consistency, but I was not able to index over the enum without importing the value.

Comment thread packages/pluggable-widgets-tools/package.json Outdated

### Added

- We added a built-in Jest mock for the `mendix` module, so widgets that import runtime values from it (e.g. `ValueStatus`, `FormatterType`) in unit tests no longer fail with "This package should not be used in the runtime".

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Blame @stdagkalakis for triggering me on the RN. I would propose to frame the change as a fix, considering it is not really a new feature.

We fixed an issue with the Jest configuration affecting unit tests for widgets importing enums from the mendix package (e.g. ValueStatus, FormatterType). It would cause tests to fail with the error "This package should not be used in the runtime".

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I agree with the Fix instead of Feature, and feel blamed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants