# @rhangai/nest-testing

> Nest test services module

Latest version **0.9.2** (published 2023-02-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install @rhangai/nest-testing
pnpm add @rhangai/nest-testing
yarn add @rhangai/nest-testing
bun add @rhangai/nest-testing
```

## Health

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

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

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.9.2 |
| Published | 2023-02-15 |
| First published | 2021-11-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 28.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | rhangai |
| Maintainers | rhangai |
| Keywords | nest, test, testing |

## Links

- npm: https://www.npmjs.com/package/@rhangai/nest-testing
- Repository: https://github.com/rhangai/node-packages
- Homepage: https://github.com/rhangai/node-packages/tree/main/packages/nest-test#readme
- Issues: https://github.com/rhangai/node-packages/issues
- npm.io page: https://npm.io/package/@rhangai/nest-testing

## 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

- 0.9.2 (latest) — 2023-02-15
- 0.9.0 — 2023-02-15
- 0.8.0 — 2023-01-30
- 0.7.0 — 2022-11-18
- 0.6.0 — 2022-08-03
- 0.5.0 — 2022-07-11
- 0.4.19 — 2022-03-02
- 0.4.14 — 2022-01-14
- 0.4.4 — 2021-11-24
- 0.4.3 — 2021-11-24
- 0.4.2 — 2021-11-24
- 0.4.1 — 2021-11-24
- 0.4.0 — 2021-11-24

## README

# @rhangai/nest-testing

## Installation

```sh
yarn add @rhangai/nest-testing @nestjs/testing jest
```

## Usage

Create your test factory

```ts
import { createTestFactory } from '@rhangai/nest-testing';

export const createTest = createTestFactory({
	imports: [],
	plugins: [],
});
```

Create a test

```ts
import { createTest } from './somewhere';
import { SomethingService } from './some.service';

describe('MyService', () => {
	const t = createTest({
		services: {
			something: SomethingService,
		},
	});

	it('should do something', () => {
		t.services.something.doSomething();
	});
});
```

## Plugins

### e2e

#### Setup

```ts
import { testPluginE2e } from '@rhangai/nest-testing/lib/e2e';

export const createTest = createTestFactory({
	plugins: [testPluginE2e()],
});
```

#### Usage

```ts
t.e2t((e2e) => {
	it('graphql', () => {
		await e2e.graphql({
			query: (gql) => gql`
				query ($id: Int!) {
					item(id: $id) {
						id
						name
					}
				}
			`,
			variables: {
				id: 1,
			},
			expect: {
				item: {
					id: 1,
					name: 'Box',
				},
			},
		});
	});
});
```

### typeorm

#### Setup

```ts
import { testPluginTypeorm } from '@rhangai/nest-testing/lib/typeorm';

export const createTest = createTestFactory({
	plugins: [testPluginTypeorm()],
});
```

#### Usage

Now you can use the typeorm module

```ts
const entities = await t.entityManager.find(EntityClass);
```

---
_Source: https://npm.io/package/@rhangai/nest-testing · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
