Skip to main content

Testing and debugging

Debug locally

Debugging your code locally follows the same process that debugging a connector locally does. The recommended approach is to start a Visual Studio Code debug window and run this command:

npm run debug

You can then set breakpoints in your code step through processes in your IDE (integrated development environment).

Test alongside a custom connector

If you want to test alongside a SaaS custom connector, the easiest way to do so is to copy the customizer code into the connector code.

For example, you want to test this connector:

export const connector = async () => {

// Get connector source config
const config = await readConfig()

// Use the vendor SDK, or implement own client as necessary, to initialize a client
const myClient = new MyClient(config)

return createConnector()
.stdTestConnection(async (context: Context, input: undefined, res: Response<StdTestConnectionOutput>) => {
logger.info("Running test connection")
res.send(await myClient.testConnection())
})
}

You can test a customizer by simply appending the customizer code to the end of the file:

// existing custom connector code
export const connector = async () => {

// Get connector source config
const config = await readConfig()

// Use the vendor SDK, or implement own client as necessary, to initialize a client
const myClient = new MyClient(config)

return createConnector()
.stdTestConnection(async (context: Context, input: undefined, res: Response<StdTestConnectionOutput>) => {
logger.info("Running test connection")
res.send(await myClient.testConnection())
})
}

// appended customizer code that will also get run
export const connectorCustomizer = async () => {

// Get connector source config
const config = await readConfig()

return createConnectorCustomizer()
.afterStdTestConnection(async (context: Context, output: StdTestConnectionOutput) => {
logger.info('Running after test connection')
return output
})
}

Now, when you run the test-connection command, the customizer after the test-connection command will also run.