Skip to content
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
522fc62
chore: migrate test config from jest to vitest
tstephen-nhs Mar 31, 2026
7aaacc5
chore: initial packages test migration
tstephen-nhs Mar 31, 2026
a8ff4ad
chore: all updatePrescriptionStatus tests now passing
tstephen-nhs Mar 31, 2026
ecc5541
chore: add yaml required by redocly
tstephen-nhs Mar 31, 2026
60e3606
chore: migrated nhsNotifyLambda tests passing
tstephen-nhs Mar 31, 2026
e20aa35
chore: migrated postDatedLambda tests passing
tstephen-nhs Mar 31, 2026
31641d9
chore: npm audit fix
tstephen-nhs Mar 31, 2026
bc9d4c7
Merge branch 'main' into aea-0000-jest-to-vitest
tstephen-nhs Apr 7, 2026
dec021f
chore: lintts
tstephen-nhs Apr 8, 2026
09621ad
Merge branch 'main' into aea-0000-jest-to-vitest
tstephen-nhs Apr 8, 2026
5828a41
Merge branch 'main' into aea-0000-jest-to-vitest
tstephen-nhs Apr 9, 2026
0d261f5
chore: npm audit fix
tstephen-nhs Apr 9, 2026
0ca7d8f
chore: exclude test helpers from coverage
tstephen-nhs Apr 9, 2026
b9d43f4
chore: sonarqube exclusions
tstephen-nhs Apr 9, 2026
0621a4e
fix: jest env vars
tstephen-nhs Apr 9, 2026
eab2479
fix: more jest references
tstephen-nhs Apr 9, 2026
0822bc5
chore: regen lock file
tstephen-nhs Apr 9, 2026
dc6bfba
chore: yaml is dev dep
tstephen-nhs Apr 9, 2026
fe807b8
fix: sonar comments
tstephen-nhs Apr 9, 2026
0679ba6
fix: global imports
tstephen-nhs Apr 9, 2026
39a0390
fix: sonar comments
tstephen-nhs Apr 9, 2026
ac49821
fix: avoid double spying
tstephen-nhs Apr 9, 2026
4cff347
chore: remove dead code
tstephen-nhs Apr 9, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 0 additions & 35 deletions jest.default.config.ts

This file was deleted.

2,667 changes: 1,488 additions & 1,179 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"@types/aws-lambda": "^8.10.161",
"@types/jest": "^30.0.0",
"@types/node": "^25.5.0",
"@vitest/coverage-v8": "^3.2.4",
"@typescript-eslint/eslint-plugin": "^8.57.2",
"@typescript-eslint/parser": "^8.57.1",
"aws-lambda": "^1.0.7",
Expand All @@ -48,6 +49,8 @@
"jest-junit": "^16.0.0",
"ts-jest": "^29.4.6",
"ts-node": "^10.9.2",
"vite-tsconfig-paths": "^5.1.4",
"vitest": "^3.2.4",
"typescript": "^5.9.3",
"typescript-eslint": "^8.57.2"
},
Expand Down
67 changes: 37 additions & 30 deletions packages/capabilityStatement/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,35 +1,42 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"name": "vscode-jest-tests.v2",
"request": "launch",
"args": [
"--runInBand",
"--watchAll=false",
"--testNamePattern",
"${jest.testNamePattern}",
"--runTestsByPath",
"${jest.testFile}",
"--config",
"${workspaceFolder}/jest.debug.config.ts"
],
"cwd": "${workspaceFolder}",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"disableOptimisticBPs": true,
"program": "${workspaceFolder}/../../node_modules/.bin/jest",
"windows": {
"program": "${workspaceFolder}/node_modules/jest/bin/jest"
},
"env": {
"POWERTOOLS_DEV": true,
"NODE_OPTIONS": "--experimental-vm-modules"
}
}
{
"type": "node",
"name": "vitest: all tests",
"request": "launch",
"program": "${workspaceFolder}/../../node_modules/vitest/vitest.mjs",
"args": [
"run",
"--config",
"${workspaceFolder}/vitest.config.ts"
],
"cwd": "${workspaceFolder}",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"disableOptimisticBPs": true,
"env": {
"POWERTOOLS_DEV": "true"
}
},
{
"type": "node",
"name": "vitest: current file",
"request": "launch",
"program": "${workspaceFolder}/../../node_modules/vitest/vitest.mjs",
"args": [
"run",
"--config",
"${workspaceFolder}/vitest.config.ts",
"${file}"
],
"cwd": "${workspaceFolder}",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"disableOptimisticBPs": true,
"env": {
"POWERTOOLS_DEV": "true"
}
}
]
}
6 changes: 1 addition & 5 deletions packages/capabilityStatement/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
{
"jest.jestCommandLine": "/workspaces/eps-prescription-status-update-api/node_modules/.bin/jest --no-cache",
"jest.nodeEnv": {
"POWERTOOLS_DEV": true,
"NODE_OPTIONS": "--experimental-vm-modules"
}
"testing.automaticallyOpenPeekView": "never"
}
9 changes: 0 additions & 9 deletions packages/capabilityStatement/jest.config.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/capabilityStatement/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"license": "MIT",
"type": "module",
"scripts": {
"unit": "POWERTOOLS_DEV=true NODE_OPTIONS=--experimental-vm-modules jest --no-cache --coverage",
"unit": "POWERTOOLS_DEV=true vitest run --config vitest.config.ts --coverage",
"lint": "eslint --max-warnings 0 --fix --config ../../eslint.config.mjs .",
"compile": "tsc",
"test": "npm run compile && npm run unit",
Expand Down
6 changes: 3 additions & 3 deletions packages/capabilityStatement/tests/test-handler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import {
expect,
describe,
it,
jest
} from "@jest/globals"
vi
} from "vitest"
import capabilityStatement from "../src/apim-medicines-prescriptionstatusupdate.json"
import {mockAPIGatewayProxyEvent, mockContext} from "@psu-common/testing"

Expand All @@ -25,7 +25,7 @@ describe("Unit test for app handler", function () {
})

it("appends trace id's to the logger", async () => {
const mockAppendKeys = jest.spyOn(Logger.prototype, "appendKeys")
const mockAppendKeys = vi.spyOn(Logger.prototype, "appendKeys")

await handler(mockAPIGatewayProxyEvent, mockContext)

Expand Down
6 changes: 6 additions & 0 deletions packages/capabilityStatement/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import {defineConfig, mergeConfig} from "vitest/config"
import defaultConfig from "../../vitest.default.config.ts"

export default mergeConfig(defaultConfig, defineConfig({
root: "./"
}))
41 changes: 23 additions & 18 deletions packages/checkPrescriptionStatusUpdates/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,34 +1,39 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"name": "vscode-jest-tests.v2",
"name": "vitest: all tests",
"request": "launch",
"program": "${workspaceFolder}/../../node_modules/vitest/vitest.mjs",
"args": [
"--runInBand",
"--watchAll=false",
"--testNamePattern",
"${jest.testNamePattern}",
"--runTestsByPath",
"${jest.testFile}",
"run",
"--config",
"${workspaceFolder}/jest.debug.config.ts"
"${workspaceFolder}/vitest.config.ts"
],
"cwd": "${workspaceFolder}",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"disableOptimisticBPs": true,
"program": "${workspaceFolder}/../../node_modules/.bin/jest",
"windows": {
"program": "${workspaceFolder}/node_modules/jest/bin/jest"
},
"env": {
"POWERTOOLS_DEV": true,
"NODE_OPTIONS": "--experimental-vm-modules"
"POWERTOOLS_DEV": "true"
}
},
{
"type": "node",
"name": "vitest: current file",
"request": "launch",
"program": "${workspaceFolder}/../../node_modules/vitest/vitest.mjs",
"args": [
"run",
"--config",
"${workspaceFolder}/vitest.config.ts",
"${file}"
],
"cwd": "${workspaceFolder}",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"env": {
"POWERTOOLS_DEV": "true"
}
}
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
{
"jest.jestCommandLine": "/workspaces/eps-prescription-status-update-api/node_modules/.bin/jest --no-cache",
"jest.nodeEnv": {
"POWERTOOLS_DEV": true,
"NODE_OPTIONS": "--experimental-vm-modules"
}
"testing.automaticallyOpenPeekView": "never"
}
10 changes: 0 additions & 10 deletions packages/checkPrescriptionStatusUpdates/jest.config.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/checkPrescriptionStatusUpdates/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"author": "NHS Digital",
"license": "MIT",
"scripts": {
"unit": "POWERTOOLS_DEV=true NODE_OPTIONS=--experimental-vm-modules jest --no-cache --coverage",
"unit": "POWERTOOLS_DEV=true vitest run --config vitest.config.ts --coverage",
"lint": "eslint --max-warnings 0 --fix --config ../../eslint.config.mjs .",
"compile": "tsc",
"test": "npm run compile && npm run unit",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable max-len */
import {buildQuery} from "../src/dynamoDBclient"
import {expect, describe} from "@jest/globals"
import {describe, expect, test} from "vitest"
import {InputData} from "../src/types"

type buildQueryTestData = {
Expand Down
28 changes: 15 additions & 13 deletions packages/checkPrescriptionStatusUpdates/tests/testHander.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import {
expect,
describe,
it,
jest
} from "@jest/globals"
beforeEach,
vi,
type Mock
} from "vitest"

import {DynamoDBDocumentClient} from "@aws-sdk/lib-dynamodb"
import {handler} from "../src/checkPrescriptionStatusUpdates"
Expand All @@ -24,13 +26,13 @@ const defaultItem = {

describe("test handler", () => {
beforeEach(() => {
jest.resetModules()
jest.clearAllMocks()
vi.resetModules()
vi.clearAllMocks()
})

it("respond with empty request and status 404 when no results returned by dynamodb", async () => {
const mockReply = generateReply(0)
jest.spyOn(DynamoDBDocumentClient.prototype, "send").mockResolvedValue(mockReply as never)
vi.spyOn(DynamoDBDocumentClient.prototype, "send").mockResolvedValue(mockReply as never)

const response = await handler(mockAPIGatewayProxyEvent, mockContext)
expect(response.statusCode).toBe(404)
Expand All @@ -41,7 +43,7 @@ describe("test handler", () => {

it("respond with success when data returned by dynamodb", async () => {
const mockReply = generateReply(1)
jest.spyOn(DynamoDBDocumentClient.prototype, "send").mockResolvedValue(mockReply as never)
vi.spyOn(DynamoDBDocumentClient.prototype, "send").mockResolvedValue(mockReply as never)

const response = await handler(mockAPIGatewayProxyEvent, mockContext)
expect(response.statusCode).toBe(200)
Expand All @@ -52,7 +54,7 @@ describe("test handler", () => {

it("respond with success and LastEvaluatedKey when paginated data returned by dynamodb", async () => {
const mockReply = generateReply(5, false)
jest.spyOn(DynamoDBDocumentClient.prototype, "send").mockResolvedValue(mockReply as never)
vi.spyOn(DynamoDBDocumentClient.prototype, "send").mockResolvedValue(mockReply as never)

const response = await handler(mockAPIGatewayProxyEvent, mockContext)
expect(response.statusCode).toBe(200)
Expand All @@ -70,7 +72,7 @@ describe("test handler", () => {

it("returns less than 5 results if that's all that's available", async () => {
const mockReply = generateReply(3)
jest.spyOn(DynamoDBDocumentClient.prototype, "send").mockResolvedValue(mockReply as never)
vi.spyOn(DynamoDBDocumentClient.prototype, "send").mockResolvedValue(mockReply as never)

const response = await handler(mockAPIGatewayProxyEvent, mockContext)
expect(response.statusCode).toBe(200)
Expand All @@ -86,7 +88,7 @@ describe("test handler", () => {

it("returns just more than 5 results", async () => {
// 6 results in 2 calls, expecting 6 results
jest
vi
.spyOn(DynamoDBDocumentClient.prototype, "send")
.mockImplementationOnce(() => {
return Promise.resolve(generateReply(3, false))
Expand All @@ -108,7 +110,7 @@ describe("test handler", () => {
})

it("returns just more than 5 results with pagination headers", async () => {
jest
vi
.spyOn(DynamoDBDocumentClient.prototype, "send")
.mockImplementationOnce(() => {
const reply = generateReply(2, false)
Expand All @@ -129,7 +131,7 @@ describe("test handler", () => {
.mockImplementationOnce(() => {
return Promise.resolve(generateReply(2))
})
const mockSend = DynamoDBDocumentClient.prototype.send as jest.Mock
const mockSend = DynamoDBDocumentClient.prototype.send as Mock

const event = JSON.parse(JSON.stringify(mockAPIGatewayProxyEvent))
event.headers["exclusivestartkey-prescriptionid"] = "prescriptionId1"
Expand All @@ -154,7 +156,7 @@ describe("test handler", () => {

it("returns no more than 15 results", async () => {
// >15 results (15 with pagination headers), expecting 15 results
jest.spyOn(DynamoDBDocumentClient.prototype, "send").mockImplementationOnce(() => {
vi.spyOn(DynamoDBDocumentClient.prototype, "send").mockImplementationOnce(() => {
return Promise.resolve(generateReply(15, false))
})

Expand All @@ -174,7 +176,7 @@ describe("test handler", () => {

it("respond with failure when dynamodb throws exception", async () => {
const mockReply = {}
jest.spyOn(DynamoDBDocumentClient.prototype, "send").mockRejectedValue(mockReply as never)
vi.spyOn(DynamoDBDocumentClient.prototype, "send").mockRejectedValue(mockReply as never)

const response = await handler(mockAPIGatewayProxyEvent, mockContext)
expect(response.statusCode).toBe(500)
Expand Down
9 changes: 9 additions & 0 deletions packages/checkPrescriptionStatusUpdates/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {defineConfig, mergeConfig} from "vitest/config"
import defaultConfig from "../../vitest.default.config.ts"

export default mergeConfig(defaultConfig, defineConfig({
root: "./",
test: {
setupFiles: ["./.jest/setEnvVars.js"]
}
}))
2 changes: 1 addition & 1 deletion packages/common/commonTypes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"types": "lib/src/index.d.ts",
"type": "module",
"scripts": {
"unit": "jest",
"unit": "vitest run --config vitest.config.ts --coverage --passWithNoTests",
"lint": "eslint --max-warnings 0 --fix --config ../../../eslint.config.mjs .",
"compile": "tsc",
"test": "npm run compile && npm run unit",
Expand Down
Loading
Loading