packages/nodes-base/TESTING.MD
To write unit tests it is suggested to use AI for help.
Create the test file: Decide which node you want to test and create a test file with the corresponding name in the test folder. For example, for a node in nodeA/v2/NodeAV2.node.ts, create a test file in nodeA/v2/test/NodeAV2.test.ts.
Use AI assistance: Send this prompt to your AI tool (Cursor, Copilot, Claude, etc.):
Using guidelines in @TESTING_PROMPT.md, write tests for @NodeAV2.node.ts in @NodeAV2.node.test.ts
Make sure file names after @ are detected and referenced by your tool.
You can improve the prompt by asking to cover specific test cases.
Review and refine: Thoroughly review the generated tests, make necessary fixes, and remove redundant tests. Even if generated by AI, it's still your responsibility to ensure tests are working and reasonable.
Workflow unit tests are tests that use user predefined workflows in json format and NodeTestHarness helper that runs the workflow. This is closer to integration tests.
For these tests you can follow the guidelines defined above, but with some modifications:
TESTING_PROMPT_WORKFLOW.md insteadI need you to write workflow unit tests for @NodeAV2.node.ts in @NodeAV2.node.test.ts
using guidelines in @TESTING_PROMPT_WORKFLOW.md
You should test each resource and operation in the node
After writing a first test make sure it passes, then write other tests.
To mock credentials use this schema
oauth2: {
scope: '',
oauthTokenData: {
access_token: 'ACCESSTOKEN',
},
}