diff --git a/api.planx.uk/jest.config.ts b/api.planx.uk/jest.config.ts index 72db933719..83139c4dd4 100644 --- a/api.planx.uk/jest.config.ts +++ b/api.planx.uk/jest.config.ts @@ -1,17 +1,16 @@ import type { JestConfigWithTsJest } from "ts-jest"; const config: JestConfigWithTsJest = { - // we don't use a preset, preferring to give an explicit manual config + // ts-jest presets are deprecated, so we prefer to give an explicit manual config testEnvironment: "node", transform: { - // esbuild-jest is unmaintained and can't handle TypeScript with ESM, so we stick to ts-jest - // TODO: if tests are slow, consider swapping out for @swc/jest + // esbuild-jest transformer is unmaintained and can't handle ts-with-esm, so we stick to ts-jest + // TODO: if tests are too slow, consider swapping out for @swc/jest "^.+\\.[jt]s$": [ "ts-jest", { useESM: true, - target: "esnext", - // we need a separate moduleResolutuion for tests (jest v30 may fix this) + // we need a separate module/moduleResolution config for tests (jest v30 may fix this) tsconfig: "tsconfig.test.json", }, ], diff --git a/api.planx.uk/modules/gis/service/digitalLand.ts b/api.planx.uk/modules/gis/service/digitalLand.ts index 91b1193ca6..6453087eb7 100644 --- a/api.planx.uk/modules/gis/service/digitalLand.ts +++ b/api.planx.uk/modules/gis/service/digitalLand.ts @@ -9,6 +9,24 @@ import { addDesignatedVariable } from "./helpers.js"; import { baseSchema } from "./local_authorities/metadata/base.js"; import { $api } from "../../../client/index.js"; +import * as barkingAndDagenham from "./local_authorities/metadata/barkingAndDagenham.js"; +import * as barnet from "./local_authorities/metadata/barnet.js"; +import * as birmingham from "./local_authorities/metadata/birmingham.js"; +import * as buckinghamshire from "./local_authorities/metadata/buckinghamshire.js"; +import * as camden from "./local_authorities/metadata/camden.js"; +import * as canterbury from "./local_authorities/metadata/canterbury.js"; +import * as doncaster from "./local_authorities/metadata/doncaster.js"; +import * as epsomAndEwell from "./local_authorities/metadata/epsomAndEwell.js"; +import * as gateshead from "./local_authorities/metadata/gateshead.js"; +import * as gloucester from "./local_authorities/metadata/gloucester.js"; +import * as lambeth from "./local_authorities/metadata/lambeth.js"; +import * as medway from "./local_authorities/metadata/medway.js"; +import * as newcastle from "./local_authorities/metadata/newcastle.js"; +import * as southwark from "./local_authorities/metadata/southwark.js"; +import * as stAlbans from "./local_authorities/metadata/stAlbans.js"; +import * as tewkesbury from "./local_authorities/metadata/tewkesbury.js"; +import * as westBerkshire from "./local_authorities/metadata/westBerkshire.js"; + export interface LocalAuthorityMetadata { planningConstraints: { article4: { @@ -19,31 +37,23 @@ export interface LocalAuthorityMetadata { /** When a team publishes their granular Article 4 data, add them to this list. Key must match team slug */ export const localAuthorityMetadata: Record = { - "barking-and-dagenham": await import( - "./local_authorities/metadata/barkingAndDagenham.js" - ), - barnet: await import("./local_authorities/metadata/barnet.js"), - birmingham: await import("./local_authorities/metadata/birmingham.js"), - buckinghamshire: await import( - "./local_authorities/metadata/buckinghamshire.js" - ), - camden: await import("./local_authorities/metadata/camden.js"), - canterbury: await import("./local_authorities/metadata/canterbury.js"), - doncaster: await import("./local_authorities/metadata/doncaster.js"), - "epsom-and-ewell": await import( - "./local_authorities/metadata/epsomAndEwell.js" - ), - gateshead: await import("./local_authorities/metadata/gateshead.js"), - gloucester: await import("./local_authorities/metadata/gloucester.js"), - lambeth: await import("./local_authorities/metadata/lambeth.js"), - medway: await import("./local_authorities/metadata/medway.js"), - newcastle: await import("./local_authorities/metadata/newcastle.js"), - southwark: await import("./local_authorities/metadata/southwark.js"), - "st-albans": await import("./local_authorities/metadata/stAlbans.js"), - tewkesbury: await import("./local_authorities/metadata/tewkesbury.js"), - "west-berkshire": await import( - "./local_authorities/metadata/westBerkshire.js" - ), + "barking-and-dagenham": barkingAndDagenham, + barnet, + birmingham, + buckinghamshire, + camden, + canterbury, + doncaster, + "epsom-and-ewell": epsomAndEwell, + gateshead, + gloucester, + lambeth, + medway, + newcastle, + southwark, + "st-albans": stAlbans, + tewkesbury, + "west-berkshire": westBerkshire, }; /** diff --git a/api.planx.uk/modules/gis/service/index.js b/api.planx.uk/modules/gis/service/index.js index c8e4e453fe..8857a2f132 100644 --- a/api.planx.uk/modules/gis/service/index.js +++ b/api.planx.uk/modules/gis/service/index.js @@ -1,7 +1,14 @@ +import * as digitalLand from "./digitalLand.js"; +import * as scotland from "./local_authorities/scotland.js"; +import * as braintree from "./local_authorities/braintree.js"; + const localAuthorities = { - braintree: await import("./local_authorities/braintree.js"), - scotland: await import("./local_authorities/scotland.js"), - digitalLand: await import("./digitalLand.js"), + // braintree: await import("./local_authorities/braintree.js"), + // scotland: await import("./local_authorities/scotland.js"), + // digitalLand: await import("./digitalLand.js"), + digitalLand, + braintree, + scotland, }; /** diff --git a/api.planx.uk/package.json b/api.planx.uk/package.json index 9ce6b28f49..8731117215 100644 --- a/api.planx.uk/package.json +++ b/api.planx.uk/package.json @@ -62,7 +62,7 @@ "lint": "eslint '**/*.{js,ts}' && prettier -c .", "lint:fix": "eslint --fix '**/*.{js,ts}' && prettier -w .", "check": "tsc --noEmit && pnpm lint", - "test": "TZ=Europe/London NODE_OPTIONS='$NODE_OPTIONS --experimental-vm-modules' jest --silent", + "test": "TZ=Europe/London NODE_OPTIONS='$NODE_OPTIONS --experimental-vm-modules' jest --no-cache", "test:coverage": "TZ=Europe/London NODE_OPTIONS='$NODE_OPTIONS --experimental-vm-modules' jest; open ./coverage/lcov-report/index.html", "test:watch": "TZ=Europe/London NODE_OPTIONS='$NODE_OPTIONS --experimental-vm-modules' jest --coverage=false --watch", "build": "rimraf ./dist && npx tsc && pnpm copy-swagger-files", @@ -116,7 +116,7 @@ "prettier": "^3.2.4", "rimraf": "^5.0.5", "supertest": "^7.0.0", - "ts-jest": "^29.2.3", + "ts-jest": "^29.2.4", "tsx": "^4.16.2", "typescript": "^5.5.2", "uuid": "^10.0.0" diff --git a/api.planx.uk/pnpm-lock.yaml b/api.planx.uk/pnpm-lock.yaml index bb7d8979df..eae4a99970 100644 --- a/api.planx.uk/pnpm-lock.yaml +++ b/api.planx.uk/pnpm-lock.yaml @@ -268,8 +268,8 @@ devDependencies: specifier: ^7.0.0 version: 7.0.0 ts-jest: - specifier: ^29.2.3 - version: 29.2.3(@babel/core@7.24.0)(esbuild@0.22.0)(jest@29.7.0)(typescript@5.5.2) + specifier: ^29.2.4 + version: 29.2.4(@babel/core@7.24.0)(esbuild@0.22.0)(jest@29.7.0)(typescript@5.5.2) tsx: specifier: ^4.16.2 version: 4.16.2 @@ -7808,8 +7808,8 @@ packages: punycode: 2.3.1 dev: false - /ts-jest@29.2.3(@babel/core@7.24.0)(esbuild@0.22.0)(jest@29.7.0)(typescript@5.5.2): - resolution: {integrity: sha512-yCcfVdiBFngVz9/keHin9EnsrQtQtEu3nRykNy9RVp+FiPFFbPJ3Sg6Qg4+TkmH0vMP5qsTKgXSsk80HRwvdgQ==} + /ts-jest@29.2.4(@babel/core@7.24.0)(esbuild@0.22.0)(jest@29.7.0)(typescript@5.5.2): + resolution: {integrity: sha512-3d6tgDyhCI29HlpwIq87sNuI+3Q6GLTTCeYRHCs7vDz+/3GCMwEtV9jezLyl4ZtnBgx00I7hm8PCP8cTksMGrw==} engines: {node: ^14.15.0 || ^16.10.0 || ^18.0.0 || >=20.0.0} hasBin: true peerDependencies: