Skip to content

Commit c68686b

Browse files
committed
Attempt to make things work with yarn berry
1 parent a87fa73 commit c68686b

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

__tests__/helpers.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
sleep,
66
sleepUntil as baseSleepUntil,
77
} from "jest-time-helpers";
8-
import * as pg from "pg";
8+
import pg from "pg";
99

1010
import defer from "../src/deferred";
1111
import {
@@ -43,10 +43,6 @@ export function sleepUntil(condition: () => boolean, ms?: number) {
4343
return baseSleepUntil(condition, ms ?? 5000);
4444
}
4545

46-
// Sometimes CI's clock can get interrupted (it is shared infra!) so this
47-
// extends the default timeout just in case.
48-
jest.setTimeout(20000);
49-
5046
// process.env.GRAPHILE_LOGGER_DEBUG = "1";
5147

5248
async function createTestDatabase() {

__tests__/nodeEnvironment.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
const NodeEnvironment = require("jest-environment-node");
1+
const { TestEnvironment } = require("jest-environment-node");
22

3-
class CustomEnvironment extends NodeEnvironment {
3+
class CustomEnvironment extends TestEnvironment {
44
constructor(config, context) {
55
super(config, context);
66
this.global.AbortController = global.AbortController;

jest.config.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
module.exports = {
22
roots: ["<rootDir>/src", "<rootDir>/__tests__"],
33
transform: {
4-
"^.+\\.tsx?$": "ts-jest",
4+
"^.+\\.tsx?$": [
5+
"ts-jest",
6+
{ tsconfig: { rootDir: ".", module: "node16" } },
7+
],
58
},
69
testRegex: "(/__tests__/.*\\.(test|spec))\\.[tj]sx?$",
710
moduleFileExtensions: ["ts", "js", "json"],
@@ -10,4 +13,5 @@ module.exports = {
1013
"^(\\.{1,2}/.*)\\.js$": "$1",
1114
},
1215
testEnvironment: "./__tests__/nodeEnvironment.js",
16+
testTimeout: 20000,
1317
};

src/lib.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import {
77
orderedApply,
88
resolvePreset,
99
} from "graphile-config";
10-
import { Client, Pool, PoolClient, PoolConfig } from "pg";
10+
import pg from "pg";
11+
import type { Pool, PoolClient, PoolConfig } from "pg";
1112

1213
import { makeWorkerPresetWorkerOptions } from "./config";
1314
import { migrations } from "./generated/sql";
@@ -234,7 +235,8 @@ export function processSharedOptions<
234235
},
235236
plugins,
236237
} = resolvedPreset;
237-
const escapedWorkerSchema = Client.prototype.escapeIdentifier(workerSchema);
238+
const escapedWorkerSchema =
239+
pg.Client.prototype.escapeIdentifier(workerSchema);
238240

239241
const ctx: WorkerPluginBaseContext = {
240242
version,
@@ -357,7 +359,7 @@ function makeNewPool(
357359
releasers: Releasers,
358360
poolOptions: PoolConfig,
359361
) {
360-
const pgPool = new Pool(poolOptions);
362+
const pgPool = new pg.Pool(poolOptions);
361363
releasers.push(() => {
362364
pgPool.end();
363365
});

0 commit comments

Comments
 (0)