Custom Node: Unit-Testing, optional authentication

I would like to write a custom node where no validation is required. In this case a json schema validator, which i would connect to an incoming webhook.

Three questions:

  • How can i write a node where an authentication is not required? It seems like that this information is part of the package.json. However all tutorials seems to require the authentication process.
  • How can i unit-test the nodes? I could not find any information about how unit-tests are written. Basically the unit test must be able to cover incoming and outgoing messages.
  • How can i run integration tests?

Hm, I am not aware of a way to include optional authentication I am afraid. I suspect the simplest approach would be simply creating a dummy auth type your users can choose from, similar to what existing nodes supporting both API tokens OAuth do. Maybe @marcus has another idea here?

1 Like

Okay, then i will wait for his reply. And what about the questions regarding unit-testing custom nodes? Is there something which we can use?

Hm, I am not sure we have much node testing in place and how this could be transferred to community nodes. The documentation only mentions manual testing and linting. I wonder if Marcus knows more about this, if not, I’ll ask the engineering team to jump in on this.

1 Like

Hey @azngeek,
did I understand right that you want to develop a json schema validator node? In that case you would not need credentials or authentication, so you could just ignore setting up the credential files and not add credentials to the package.json.

To validate schemas it would be best to develop a programmatic-style node. We had a node-athon up until a week ago and there were some nodes submitted that you could take for inspiration

We do not have an easy way to do unit-testing for node development. Internally we use workflows to test nodes, so we import and execute all test workflows using our cli.

2 Likes

Great. This will be a good starting point.