Custom n8n node throws credential testing error despite having test function defined

I’m working on a custom n8n node for PostgreSQL integration and running into an issue with credential validation. The system keeps throwing an error saying there’s no test function available for my credentials, even though I’ve defined one properly.

In my main node file, I’m specifying that credentials should be validated using a function named validateCredentials:

credentials: [
    {
        name: 'pgConnection',
        required: true,
        testedBy: 'validateCredentials'
    }
],

The validation function is set up in the methods section like this:

methods = {
    loadOptions: {
        getDatabases
    },
    // credential validation function goes here:
    credentialTest: {
        validateCredentials /** imported from external module */
    }
};

My validation function implements the proper interface signature: ICredentialTestFunction = (this: ICredentialTestFunctions, credential: ICredentialsDecrypted) => Promise<INodeCredentialTestResult>

I’ve looked at how other database nodes like PostgreSQL handle this and my setup seems identical to theirs, but somehow the test function isn’t being recognized. Any ideas what might be causing this?

check if you’re exporting the methods obj correctly from your node class. had the same problem - forgot the async keyword in my validation function. also, ensure your credential test function returns a promise with the right success/error props. sometimes n8n won’t pick it up if there’s a syntax error anywhere.

This happens when your credential test method structure doesn’t match what n8n expects. You’re using credentialTest inside the methods object, but n8n wants it as a direct property, not nested. Restructure your methods like this:

methods = {
    loadOptions: {
        getDatabases
    },
    credentialTest: {
        validateCredentials
    }
};

Also check that your credential definition file has the test method set up correctly. I’ve seen nodes reference the test function fine, but the actual credential class is missing the test method. Another thing to watch - make sure ‘pgConnection’ matches exactly in both your node and credential files, including capitalization.

Had this exact same issue when building a custom Slack integration node last month. The problem’s likely in your function export structure. Make sure your validateCredentials function is properly exported from the external module and that the import path is correct. Also double-check that your credential file has the proper test property pointing to the same function name. I found that n8n is quite picky about the exact naming convention - the function name in testedBy must match exactly what’s in your credentialTest object. Try adding some console logs in your validation function to see if it’s even being called. Another thing to verify - your credential class extends ICredentialType properly and the credential name matches between your node and credential files.