# express-test-utils

> Package with some utility functions for testing express apps

Latest version **1.1.6** (published 2023-01-22) · ISC license · 0 weekly downloads

## Install

```sh
npm install express-test-utils
pnpm add express-test-utils
yarn add express-test-utils
bun add express-test-utils
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.6 |
| Published | 2023-01-22 |
| First published | 2022-12-22 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 9 |
| Unpacked size | 16.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Hugo Phibbs |
| Maintainers | hugophibbs |
| Keywords | testing, express, express-validator, utils, utilities |

## Links

- npm: https://www.npmjs.com/package/express-test-utils
- Repository: https://github.com/HugoPhibbs/express-test-utils
- Homepage: https://github.com/HugoPhibbs/express-test-utils#readme
- Issues: https://github.com/HugoPhibbs/express-test-utils/issues
- npm.io page: https://npm.io/package/express-test-utils

## Dependencies (9)

- [jest](https://npm.io/package/jest.md) ^29.3.1
- [sinon](https://npm.io/package/sinon.md) ^15.0.1
- [lodash](https://npm.io/package/lodash.md) ^4.17.21
- [express](https://npm.io/package/express.md) ^4.18.2
- [prettier](https://npm.io/package/prettier.md) ^2.8.1
- [@types/express](https://npm.io/package/@types/express.md) ^4.17.15
- [node-mocks-http](https://npm.io/package/node-mocks-http.md) ^1.12.1
- [express-validator](https://npm.io/package/express-validator.md) ^6.14.2
- [jest-expect-message](https://npm.io/package/jest-expect-message.md) ^1.1.3

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads
- [aws-elasticsearch-connector](https://npm.io/package/aws-elasticsearch-connector.md) — 37.4K weekly downloads

## Recent versions

- 1.1.6 (latest) — 2023-01-22
- 1.1.5 — 2023-01-12
- 1.1.4 — 2023-01-12
- 1.1.3 — 2023-01-12
- 1.1.2 — 2023-01-11
- 1.1.1 — 2023-01-10
- 1.1.0 — 2023-01-10
- 1.0.9 — 2023-01-09
- 1.0.8 — 2023-01-09
- 1.0.7 — 2023-01-09
- 1.0.6 — 2022-12-23
- 1.0.5 — 2022-12-23
- 1.0.4 — 2022-12-23
- 1.0.3 — 2022-12-23
- 1.0.2 — 2022-12-23
- … 2 more at https://npm.io/package/express-test-utils/versions

## README

# express-test-utils

![Node Build](https://github.com/HugoPhibbs/express-test-utils/actions/workflows/node.js.yml/badge.svg)

-   Package for random express utility testing functions that I use regularly
-   Documentation can be found [here](https://hugophibbs.github.io/express-test-utils/)

## Installation

```shell
npm install express-test-utils
```

### Setup

-   For versions 1.1.0 and above, you may encounter issues with Jest complaining about `expect` requiring just one argument. This occurs since my package relies on [jest-expect-message](https://www.npmjs.com/package/jest-expect-message) to provide expect messages. To fix this, follow steps in **Setup** on jest-expect-message's [readme](https://www.npmjs.com/package/jest-expect-message#readme). Which pretty much replaces the `expect` definition for your project

## Usage

```typescript
const testUtils = require("express-test-utils");

testUtils.testValidationChain(args);

// Or whatever else you wish to do
```

## Functions

-   See documentation linked above for full details

-   `testRequiredBodyValues(paths, body, chain)` tests whether given body values are required by a validation chain
-   `checkForValidationErrors(req, chain, shouldBeNoErrors)` checks for any validation errors against whether a request should pass a chain or not
-   `checkRequestAuthentication(req, auth)` checks if a request passes authentication with given function or not
-   `checkForValidationErrors(req, res, chain)` checks for any express-validator validation errors for running the given request through the given chain

## Contributing

-   If you would like to leave feedback or suggestions, please refer to our issues [page](https://github.com/HugoPhibbs/express-test-utils/issues).
-   PRs are welcome

---
_Source: https://npm.io/package/express-test-utils · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
