@snowtop/ent-graphql-tests
Version:
easy ways to test ent and graphql
42 lines (41 loc) • 1.47 kB
TypeScript
import { Express, RequestHandler } from "express";
import { Viewer } from "@snowtop/ent";
import { GraphQLSchema } from "graphql";
import supertest from "supertest";
export type Option = [string, any] | [string, any, string];
interface queryConfig {
viewer?: Viewer;
init?: (app: Express) => void;
test?: supertest.SuperTest<supertest.Test> | ((express: Express) => supertest.SuperTest<supertest.Test>);
schema: GraphQLSchema;
headers?: object;
debugMode?: boolean;
args: {};
extraVariables?: {
[key: string]: {
graphqlType: string;
value: string;
};
};
expectedStatus?: number;
expectedError?: string | RegExp;
callback?: (res: supertest.Response) => void;
inlineFragmentRoot?: string;
customHandlers?: RequestHandler[];
server?: any;
graphQLPath?: string;
}
export interface queryRootConfig extends queryConfig {
root: string;
rootQueryNull?: boolean;
nullQueryPaths?: string[];
undefinedQueryPaths?: string[];
}
export declare function expectQueryFromRoot(config: queryRootConfig, ...options: Option[]): Promise<supertest.SuperTest<supertest.Test>>;
export interface mutationRootConfig extends queryConfig {
mutation: string;
disableInputWrapping?: boolean;
nullQueryPaths?: string[];
}
export declare function expectMutation(config: mutationRootConfig, ...options: Option[]): Promise<supertest.SuperTest<supertest.Test>>;
export {};