[WTF-2710]: Fix unit tests failing on ValueStatus import#191
[WTF-2710]: Fix unit tests failing on ValueStatus import#191alihcsumer wants to merge 6 commits into
Conversation
|
I like the approach proposed in !192 better, since it follows a pattern we already use for mocking other parts of the 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. |
|
|
||
| ### 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". |
There was a problem hiding this comment.
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
mendixpackage (e.g.ValueStatus,FormatterType). It would cause tests to fail with the error "This package should not be used in the runtime".
There was a problem hiding this comment.
I agree with the Fix instead of Feature, and feel blamed
Checklist
This PR contains
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."