From 762dd4efbe47edd5fea16acf3fdbe2fdf87b9d64 Mon Sep 17 00:00:00 2001 From: Anna Bocharova Date: Tue, 15 Oct 2024 22:57:15 +0200 Subject: [PATCH] Fix: exposing `testMiddleware` (#2102) Fixes #2101 --- CHANGELOG.md | 9 ++++++++- README.md | 1 + src/index.ts | 2 +- tests/unit/__snapshots__/index.spec.ts.snap | 3 +++ 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 83f9f03ec..9bf0dc359 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ ## Version 20 +### v20.14.3 + +- Fixed: missing export of `testMiddleware`: + - The feature introduced in v20.4.0 but was not available; + - The issue reported by [@Tomtec331](https://github.com/Tomtec331). + ### v20.14.2 - Documentation: promoting Express 5 as the recommended version for new projects; @@ -197,7 +203,8 @@ declare module "express-zod-api" { - Feat: middleware testing helper: `testMiddleware()`, similar to `testEndpoint()`: - There is also an ability to pass `options` collected from outputs of previous middlewares, if the one being tested somehow depends on them. - - The method returns: `Promise<{ output, requestMock, responseMock, loggerMock }>`. + - The method returns: `Promise<{ output, requestMock, responseMock, loggerMock }>`; + - Export fixed in v20.14.3. ```typescript import { z } from "zod"; diff --git a/README.md b/README.md index 9cf6a3fb1..6402238ad 100644 --- a/README.md +++ b/README.md @@ -83,6 +83,7 @@ Therefore, many basic tasks can be accomplished faster and easier, in particular These people contributed to the improvement of the library by reporting bugs, making changes and suggesting ideas: +[@Tomtec331](https://github.com/Tomtec331) [@rottmann](https://github.com/rottmann) [@boarush](https://github.com/boarush) [@daniel-white](https://github.com/daniel-white) diff --git a/src/index.ts b/src/index.ts index 29c105a8f..08d7e1788 100644 --- a/src/index.ts +++ b/src/index.ts @@ -29,7 +29,7 @@ export { InputValidationError, MissingPeerError, } from "./errors"; -export { testEndpoint } from "./testing"; +export { testEndpoint, testMiddleware } from "./testing"; export { Integration } from "./integration"; export { ez } from "./proprietary-schemas"; diff --git a/tests/unit/__snapshots__/index.spec.ts.snap b/tests/unit/__snapshots__/index.spec.ts.snap index ce437b76d..41d70888c 100644 --- a/tests/unit/__snapshots__/index.spec.ts.snap +++ b/tests/unit/__snapshots__/index.spec.ts.snap @@ -93,9 +93,12 @@ exports[`Index Entrypoint > exports > should have certain entities exposed 1`] = "InputValidationError", "MissingPeerError", "testEndpoint", + "testMiddleware", "Integration", "ez", ] `; exports[`Index Entrypoint > exports > testEndpoint should have certain value 1`] = `[Function]`; + +exports[`Index Entrypoint > exports > testMiddleware should have certain value 1`] = `[Function]`;