From 73a0aaa45a1f1d4d80e8adbff2d9276a75bdd0c8 Mon Sep 17 00:00:00 2001 From: julescarbon Date: Thu, 19 Jan 2023 22:42:29 +0100 Subject: [PATCH] Update jest-environment-knex.ts Per https://jestjs.io/docs/28.x/upgrading-to-jest28#custom-environment the Jest custom environment constructor now takes an object as its first argument, containing `{globalConfig, projectConfig}` - previously this was just `projectConfig`. Jest is now at v29 but this is the only issue I've found so far in upgrading this test environment. --- src/jest-environment-knex.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/jest-environment-knex.ts b/src/jest-environment-knex.ts index 7efe58d3..168d4252 100644 --- a/src/jest-environment-knex.ts +++ b/src/jest-environment-knex.ts @@ -21,7 +21,7 @@ export default class KnexEnvironment extends NodeEnvironment { private destroyPromises: any = []; private options: Knex.Config; - constructor(config: Config.ProjectConfig) { + constructor(config: Config) { super(config); debug("super(config)"); @@ -41,12 +41,12 @@ export default class KnexEnvironment extends NodeEnvironment { Object.assign(this.context, config.testEnvironmentOptions) )); const prefix = - config.testEnvironmentOptions.prefix || "jest_environment_knex"; + config.projectConfig.testEnvironmentOptions.prefix || "jest_environment_knex"; global.databaseName = `${prefix}_${uid(16).toLowerCase()}`; // - this.options = config.testEnvironmentOptions; + this.options = config.projectConfig.testEnvironmentOptions; } public async setup() {