Tests

Testing

Axolotl encourages testing resolvers directly. You can reuse the same type‑safe resolvers in tests and run them with your preferred framework.

Below we split the backend into small units and test with Node’s built‑in node:test runner.

setup.ts
export const axolotl = Axolotl(yourAdapter)<Models>();
resolvers.ts
import { axolotl } from './setup.js'
export const resolvers = axolotl.createResolvers({
  Query: {
    hello: () => "World"
  },
});

So in this file we test

index.test.ts
import test from 'node:test';
import assert from 'node:assert';
import { resolvers } from './resolvers.js';
 
test('Query.hello returns World', () => {
  const result = resolvers.Query.hello();
  assert.equal(result, 'World');
});

For end‑to‑end testing, start your server (Yoga/Apollo) and run full GraphQL queries using your HTTP test client of choice.