@envelop/testing 4.4.1 → 4.4.2-alpha-1eb54ef.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@envelop/testing",
3
- "version": "4.4.1",
3
+ "version": "4.4.2-alpha-1eb54ef.0",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
- "@envelop/core": "^2.4.1",
7
- "@envelop/types": "^2.3.0",
6
+ "@envelop/core": "2.4.2-alpha-1eb54ef.0",
7
+ "@envelop/types": "2.3.1-alpha-1eb54ef.0",
8
8
  "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
9
9
  },
10
10
  "dependencies": {
@@ -27,7 +27,7 @@
27
27
  "exports": {
28
28
  ".": {
29
29
  "require": {
30
- "types": "./typings/index.d.ts",
30
+ "types": "./typings/index.d.cts",
31
31
  "default": "./cjs/index.js"
32
32
  },
33
33
  "import": {
@@ -41,7 +41,7 @@
41
41
  },
42
42
  "./*": {
43
43
  "require": {
44
- "types": "./typings/*.d.ts",
44
+ "types": "./typings/*.d.cts",
45
45
  "default": "./cjs/*.js"
46
46
  },
47
47
  "import": {
@@ -0,0 +1,55 @@
1
+ /// <reference types="jest" />
2
+ import { DocumentNode, ExecutionResult, GraphQLSchema } from 'graphql';
3
+ import { PluginOrDisabledPlugin } from '@envelop/core';
4
+ import { GetEnvelopedFn, Plugin } from '@envelop/types';
5
+ export declare type ModifyPluginsFn = (plugins: Plugin<any>[]) => Plugin<any>[];
6
+ export declare type PhaseReplacementParams = {
7
+ phase: 'parse';
8
+ fn: ReturnType<GetEnvelopedFn<any>>['parse'];
9
+ } | {
10
+ phase: 'validate';
11
+ fn: ReturnType<GetEnvelopedFn<any>>['validate'];
12
+ } | {
13
+ phase: 'execute';
14
+ fn: ReturnType<GetEnvelopedFn<any>>['execute'];
15
+ } | {
16
+ phase: 'subscribe';
17
+ fn: ReturnType<GetEnvelopedFn<any>>['subscribe'];
18
+ } | {
19
+ phase: 'contextFactory';
20
+ fn: () => any | Promise<any>;
21
+ };
22
+ export declare function createSpiedPlugin(): {
23
+ reset: () => void;
24
+ spies: {
25
+ beforeParse: jest.Mock<jest.Mock<any, any>, []>;
26
+ beforeValidate: jest.Mock<jest.Mock<any, any>, []>;
27
+ beforeContextBuilding: jest.Mock<jest.Mock<any, any>, []>;
28
+ beforeExecute: jest.Mock<{
29
+ onExecuteDone: jest.Mock<any, any>;
30
+ }, []>;
31
+ onResolverCalled: jest.Mock<jest.Mock<any, any>, []>;
32
+ onSchemaChange: jest.Mock<any, any>;
33
+ afterParse: jest.Mock<any, any>;
34
+ afterValidate: jest.Mock<any, any>;
35
+ afterContextBuilding: jest.Mock<any, any>;
36
+ afterExecute: jest.Mock<any, any>;
37
+ afterResolver: jest.Mock<any, any>;
38
+ beforeResolver: jest.Mock<jest.Mock<any, any>, []>;
39
+ };
40
+ plugin: Plugin<{}>;
41
+ };
42
+ declare type MaybePromise<T> = T | Promise<T>;
43
+ declare type MaybeAsyncIterableIterator<T> = T | AsyncIterableIterator<T>;
44
+ declare type ExecutionReturn = MaybeAsyncIterableIterator<ExecutionResult>;
45
+ export declare type TestkitInstance = {
46
+ execute: (operation: DocumentNode | string, variables?: Record<string, any>, initialContext?: any) => MaybePromise<ExecutionReturn>;
47
+ modifyPlugins: (modifyPluginsFn: ModifyPluginsFn) => void;
48
+ mockPhase: (phaseReplacement: PhaseReplacementParams) => void;
49
+ wait: (ms: number) => Promise<void>;
50
+ };
51
+ export declare function createTestkit(pluginsOrEnvelop: GetEnvelopedFn<any> | Array<PluginOrDisabledPlugin>, schema?: GraphQLSchema): TestkitInstance;
52
+ export declare function assertSingleExecutionValue(input: ExecutionReturn): asserts input is ExecutionResult;
53
+ export declare function assertStreamExecutionValue(input: ExecutionReturn): asserts input is AsyncIterableIterator<ExecutionResult>;
54
+ export declare const collectAsyncIteratorValues: <TType>(asyncIterable: AsyncIterableIterator<TType>) => Promise<TType[]>;
55
+ export {};