graphile-test 2.8.7 → 2.8.9
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/README.md +14 -1
- package/esm/get-connections.js +5 -3
- package/esm/index.js +1 -2
- package/esm/utils.js +1 -0
- package/get-connections.d.ts +2 -1
- package/get-connections.js +5 -3
- package/index.d.ts +1 -2
- package/index.js +2 -2
- package/package.json +5 -5
- package/utils.d.ts +1 -0
- package/utils.js +17 -0
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
<img height="20" src="https://img.shields.io/badge/license-MIT-blue.svg"/>
|
|
13
13
|
</a>
|
|
14
14
|
<a href="https://www.npmjs.com/package/graphile-test">
|
|
15
|
-
<img height="20" src="https://img.shields.io/github/package-json/v/launchql/launchql?filename=
|
|
15
|
+
<img height="20" src="https://img.shields.io/github/package-json/v/launchql/launchql?filename=graphile%2Fgraphile-test%2Fpackage.json"/>
|
|
16
16
|
</a>
|
|
17
17
|
</p>
|
|
18
18
|
|
|
@@ -194,6 +194,19 @@ expect(result.data.createUser.username).toBe('alice');
|
|
|
194
194
|
* Start with `getConnections()` for most use cases.
|
|
195
195
|
* Consider `getConnectionsUnwrapped()` for cleaner test assertions.
|
|
196
196
|
|
|
197
|
+
## Snapshot Utilities
|
|
198
|
+
|
|
199
|
+
The `graphile-test/utils` module provides utilities for sanitizing query results for snapshot testing. These helpers replace dynamic values (IDs, UUIDs, dates, hashes) with stable placeholders, making snapshots deterministic.
|
|
200
|
+
|
|
201
|
+
```ts
|
|
202
|
+
import { snapshot } from 'graphile-test/utils';
|
|
203
|
+
|
|
204
|
+
const res = await query(`query { allUsers { nodes { id name createdAt } } }`);
|
|
205
|
+
expect(snapshot(res.data)).toMatchSnapshot();
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
See [`pgsql-test` Snapshot Utilities](https://www.npmjs.com/package/pgsql-test#snapshot-utilities) for the full API reference.
|
|
209
|
+
|
|
197
210
|
---
|
|
198
211
|
|
|
199
212
|
## Education and Tutorials
|
package/esm/get-connections.js
CHANGED
|
@@ -27,7 +27,8 @@ const createConnectionsBase = async (input, seedAdapters) => {
|
|
|
27
27
|
db,
|
|
28
28
|
teardown,
|
|
29
29
|
baseQuery,
|
|
30
|
-
baseQueryPositional
|
|
30
|
+
baseQueryPositional,
|
|
31
|
+
gqlContext
|
|
31
32
|
};
|
|
32
33
|
};
|
|
33
34
|
// ============================================================================
|
|
@@ -37,12 +38,13 @@ const createConnectionsBase = async (input, seedAdapters) => {
|
|
|
37
38
|
* Creates connections with raw GraphQL responses
|
|
38
39
|
*/
|
|
39
40
|
export const getConnectionsObject = async (input, seedAdapters) => {
|
|
40
|
-
const { pg, db, teardown, baseQuery } = await createConnectionsBase(input, seedAdapters);
|
|
41
|
+
const { pg, db, teardown, baseQuery, gqlContext } = await createConnectionsBase(input, seedAdapters);
|
|
41
42
|
return {
|
|
42
43
|
pg,
|
|
43
44
|
db,
|
|
44
45
|
teardown,
|
|
45
|
-
query: baseQuery
|
|
46
|
+
query: baseQuery,
|
|
47
|
+
gqlContext
|
|
46
48
|
};
|
|
47
49
|
};
|
|
48
50
|
/**
|
package/esm/index.js
CHANGED
package/esm/utils.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from 'pgsql-test/utils';
|
package/get-connections.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { GetConnectionOpts } from 'pgsql-test';
|
|
2
2
|
import type { SeedAdapter } from 'pgsql-test/seed/types';
|
|
3
3
|
import type { PgTestClient } from 'pgsql-test/test-client';
|
|
4
|
-
import type { GetConnectionsInput, GraphQLQueryFn, GraphQLQueryFnObj, GraphQLQueryUnwrappedFn, GraphQLQueryUnwrappedFnObj } from './types';
|
|
4
|
+
import type { GetConnectionsInput, GraphQLQueryFn, GraphQLQueryFnObj, GraphQLQueryUnwrappedFn, GraphQLQueryUnwrappedFnObj, GraphQLTestContext } from './types';
|
|
5
5
|
/**
|
|
6
6
|
* Creates connections with raw GraphQL responses
|
|
7
7
|
*/
|
|
@@ -10,6 +10,7 @@ export declare const getConnectionsObject: (input: GetConnectionsInput & GetConn
|
|
|
10
10
|
db: PgTestClient;
|
|
11
11
|
teardown: () => Promise<void>;
|
|
12
12
|
query: GraphQLQueryFnObj;
|
|
13
|
+
gqlContext: GraphQLTestContext;
|
|
13
14
|
}>;
|
|
14
15
|
/**
|
|
15
16
|
* Creates connections with unwrapped GraphQL responses (throws on errors)
|
package/get-connections.js
CHANGED
|
@@ -30,7 +30,8 @@ const createConnectionsBase = async (input, seedAdapters) => {
|
|
|
30
30
|
db,
|
|
31
31
|
teardown,
|
|
32
32
|
baseQuery,
|
|
33
|
-
baseQueryPositional
|
|
33
|
+
baseQueryPositional,
|
|
34
|
+
gqlContext
|
|
34
35
|
};
|
|
35
36
|
};
|
|
36
37
|
// ============================================================================
|
|
@@ -40,12 +41,13 @@ const createConnectionsBase = async (input, seedAdapters) => {
|
|
|
40
41
|
* Creates connections with raw GraphQL responses
|
|
41
42
|
*/
|
|
42
43
|
const getConnectionsObject = async (input, seedAdapters) => {
|
|
43
|
-
const { pg, db, teardown, baseQuery } = await createConnectionsBase(input, seedAdapters);
|
|
44
|
+
const { pg, db, teardown, baseQuery, gqlContext } = await createConnectionsBase(input, seedAdapters);
|
|
44
45
|
return {
|
|
45
46
|
pg,
|
|
46
47
|
db,
|
|
47
48
|
teardown,
|
|
48
|
-
query: baseQuery
|
|
49
|
+
query: baseQuery,
|
|
50
|
+
gqlContext
|
|
49
51
|
};
|
|
50
52
|
};
|
|
51
53
|
exports.getConnectionsObject = getConnectionsObject;
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -14,11 +14,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.seed = void 0;
|
|
18
|
-
__exportStar(require("./clean"), exports);
|
|
17
|
+
exports.snapshot = exports.seed = void 0;
|
|
19
18
|
__exportStar(require("./context"), exports);
|
|
20
19
|
__exportStar(require("./get-connections"), exports);
|
|
21
20
|
__exportStar(require("./graphile-test"), exports);
|
|
22
21
|
__exportStar(require("./types"), exports);
|
|
23
22
|
var pgsql_test_1 = require("pgsql-test");
|
|
24
23
|
Object.defineProperty(exports, "seed", { enumerable: true, get: function () { return pgsql_test_1.seed; } });
|
|
24
|
+
Object.defineProperty(exports, "snapshot", { enumerable: true, get: function () { return pgsql_test_1.snapshot; } });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "graphile-test",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.9",
|
|
4
4
|
"author": "Dan Lynch <pyramation@gmail.com>",
|
|
5
5
|
"description": "PostGraphile Testing",
|
|
6
6
|
"main": "index.js",
|
|
@@ -31,14 +31,14 @@
|
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/pg": "^8.15.2",
|
|
33
33
|
"graphql-tag": "2.12.6",
|
|
34
|
-
"makage": "^0.1.
|
|
34
|
+
"makage": "^0.1.8"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@launchql/types": "^2.8.
|
|
37
|
+
"@launchql/types": "^2.8.6",
|
|
38
38
|
"graphql": "15.10.1",
|
|
39
39
|
"mock-req": "^0.2.0",
|
|
40
40
|
"pg": "^8.16.0",
|
|
41
|
-
"pgsql-test": "^2.14.
|
|
41
|
+
"pgsql-test": "^2.14.12",
|
|
42
42
|
"postgraphile": "^4.14.1"
|
|
43
43
|
},
|
|
44
44
|
"keywords": [
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"launchql",
|
|
49
49
|
"test"
|
|
50
50
|
],
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "3812f24a480b2035b3413ec7fecfe492f294e590"
|
|
52
52
|
}
|
package/utils.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from 'pgsql-test/utils';
|
package/utils.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("pgsql-test/utils"), exports);
|