0.9.2 • Published 1 year ago

@rhangai/nest-testing v0.9.2

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

@rhangai/nest-testing

Installation

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

Usage

Create your test factory

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

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

Create a test

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

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

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

Usage

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

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

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

Usage

Now you can use the typeorm module

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

1 year ago

0.8.0

1 year ago

0.9.2

1 year ago

0.7.0

1 year ago

0.5.0

2 years ago

0.6.0

2 years ago

0.4.19

2 years ago

0.4.14

2 years ago

0.4.4

2 years ago

0.4.3

2 years ago

0.4.2

2 years ago

0.4.1

2 years ago

0.4.0

2 years ago