node-red / node-red-node-test-helper

A test framework for Node-RED nodes
Apache License 2.0
57 stars 40 forks source link

helper.settings() cannot be called more than once with the same settings instance as parameter #35

Open cdlans opened 5 years ago

cdlans commented 5 years ago

I am very happy that it is now possible to initialise the helper with settings. However I found out that calling helper.settings(userSettings) more than once with the same instance of userSettings will cause the helper.load() to fail. This will happen if one reuses the userSettings for multiple tests.

This is because the helper defines getters and setters on the userSettings.functionGlobalContext. When it tries to do so for the second time it throws an exception, because it cannot overwrite the getters and setters.

As a work-around, it is possible to pass in a new instance of userSettings (without getters and setters) to helper.settings() for every invocation.

Tests demonstrating this issue.