Skip to main content


The collaboration server comes with a testing suite to test your resolvers.

The testing suite will perform a set of reads/write from your database using your resolvers, and inform you if any information is incorrect/missing.


The testing suite reads and writes testing data to/from your database. This may be a destructive operation.

⚠️ Please make sure to run the testing suite against an empty database. ⚠️


To use the test suite, create a node script that imports the testing suite and calls it against your resolvers.

The second parameter should be the getNow function that you also pass into the CollabServer constructor. This parameter is options, but recommended.

// testResolvers.js
import TestResolvers from '@pdftron/collab-server/tests/resolvers'
// import your resolvers and `getNow` function
import myResolvers, { getNow } from './resolvers.js';
(async () => {
const errors = await TestResolvers(myResolvers, getNow);
if(errors.length === 0) {
// If there are errors, log them
errors.forEach(error => {
console.log(JSON.stringify(error, null, 2))

Then, execute the script

node testResolvers.js


The TestResolvers function will resolve with an array of error objects. If the array is empty, your resolvers are good to go!

Each error object contains the following information:

  • resolver (string) the name of the resolver with an error
  • queryParams (string) a JSON string containing the params that were passed into the resolver
  • error (object) information about the error
    • type (string) the type of error. One of data_type_invalid, data_missing, data_invalid or resolver_missing
    • property (string) the name of the property that is invalid
    • expected (any) the data that was expected
    • received (any) the data that was received
    • message (string) an error message