Skip to content

Commit

Permalink
ATO-1237: fix test running in github
Browse files Browse the repository at this point in the history
 - Due to a a difference in node version from the lambda and Github (18,20) this has caused
   a know issue where node uses ipv4 or ipv6 by default depending on node version.
   Setting the localhost to a default ipv4 has not worked. This has caused some de synced
   behaviour when running the pact tests and due to the code setting the httpAgent in axios
   is a bigger change than we would like at this moment. Solution is to seperate out the running of
   the pact tests for now. More information on: pact-foundation/pact-js#1066
  • Loading branch information
isaac-GDS committed Jan 14, 2025
1 parent 9d15b70 commit ecd5cfd
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
2 changes: 1 addition & 1 deletion backend/api/tests/contract-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"build": "npm run buildts && npm run buildjs",
"publish": "node dist/provider/publish.js",
"test": "npm run jest && publish",
"test:pact": "jest"
"test:pact": "jest --detectOpenHandles -runInBand"
},
"author": "",
"license": "ISC",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,19 @@ import {clientRegistryResponse} from "../../../src/handlers/types/client-registr
import {mockLambdaContext} from "../../handlers/utils";
import {updateClientInRegistryHandler, UpdateClientPayload} from "../../../src/handlers/auth/update-client";

beforeAll((): void => {
jest.setTimeout(200000);
});

describe("ClientRegistryProvider", () => {
const {like} = MatchersV3;

const provider = new PactV3({
dir: path.resolve(process.cwd(), "pacts"),
logLevel: "debug",
port: 8080,
consumer: "SSEAdminAPIClient",
provider: "ClientRegistryProvider"
});

describe("When a POST request is made to create a client", () => {
const provider = new PactV3({
dir: path.resolve(process.cwd(), "pacts"),
logLevel: "debug",
port: 8080,
host: "127.0.0.1",
consumer: "SSEAdminAPIClient",
provider: "ClientRegistryProvider"
});

const postEvent: RegisterClientPayload = {
contactEmail: "[email protected]",
service: {
Expand Down Expand Up @@ -88,6 +85,15 @@ describe("ClientRegistryProvider", () => {
});

describe("When a PUT request is made to update a client", () => {
const provider = new PactV3({
dir: path.resolve(process.cwd(), "pacts"),
logLevel: "debug",
port: 8081,
host: "127.0.0.1",
consumer: "SSEAdminAPIClient",
provider: "ClientRegistryProvider"
});

const updatesForClient = {
contacts: ["[email protected]"],
subject_type: "pairwise"
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
"list": "infrastructure/dev/deploy.sh list",
"open": "infrastructure/dev/deploy.sh open",
"creds": "infrastructure/aws.sh",
"test": "jest --silent",
"test:cov": "jest --silent --coverage",
"test": "jest --runInBand",
"test:cov": "jest --coverage",
"lint": "prettier . --check ; eslint '*.ts' --quiet --fix",
"lint:fix": "prettier . --write ; eslint . --fix",
"pii-scan": "infrastructure/dev/pii_scan.sh -p *template*.yml -i infrastructure/config/pii_scan_ignore.txt -s infrastructure/config/pii_scan_skip.txt"
Expand Down

0 comments on commit ecd5cfd

Please sign in to comment.