You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Running npm run test should not yield any errors when tests are actually passing.
For example, we run it once:
and then run it again, filtering on powermodule:
The tests pass but errors are output because of the ROS queries.
Current Behavior
Errors because some modules, when tested, try to subscribe to ROS topics.
Possible Solution
There are 3 main solutions:
Make the modules as generic as possible, and use a decorator around them that makes the call to ROS. This way, when we test, we only test the wrapped module and not the wrapper that actually calls ROS:
// Example<ROSSubscriberroute="/provider_power/power"messageType="sonia_common/PowerMsg">
// ROSSubscriber "injects" PowerModule with the message from topics
<PowerModule/></ROSSubscriber>
In this example, we would only test <PowerModule /> with dummy datas.
2. Another way would be to add conditional logic in the useROSTopicSubscriber. We could check if we are currently in a test/jest context, with something like
This way, we don't have to add wrapper components. ⚠️ This is not so easy though because we are using hooks so we can't either return a context or 'nothing'...
3. Another way, not so ideal, is to change the affected components into non-functional components (so they would have more 'lifecycle' methods. The goal would be to use a conditional statement (like method 2) and only subscribe or publish to ROS when we are not testing.
Comments
N/A.
Environment Used
N/A.
The text was updated successfully, but these errors were encountered:
Expected Enhancement
Running
npm run test
should not yield any errors when tests are actually passing.For example, we run it once:
and then run it again, filtering on
powermodule
:The tests pass but errors are output because of the ROS queries.
Current Behavior
Errors because some modules, when tested, try to subscribe to ROS topics.
Possible Solution
There are 3 main solutions:
In this example, we would only test
<PowerModule />
with dummy datas.2. Another way would be to add conditional logic in the
useROSTopicSubscriber
. We could check if we are currently in a test/jest context, with something likeThis way, we don't have to add wrapper components.⚠️ This is not so easy though because we are using hooks so we can't either return a context or 'nothing'...
3. Another way, not so ideal, is to change the affected components into non-functional components (so they would have more 'lifecycle' methods. The goal would be to use a conditional statement (like method 2) and only subscribe or publish to ROS when we are not testing.
Comments
N/A.
Environment Used
N/A.
The text was updated successfully, but these errors were encountered: