How to use the jest.describe function in jest

To help you get started, we’ve selected a few jest examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github TeamHive / nestjs-seed / src / app / modules / users / user.controller.spec.ts View on Github external
describe('UserController', () => {
    let userController: UserController;
    let userService: UserService;

    beforeEach(async () => {
        const module = await Test.createTestingModule({
            controllers: [UserController],
            components: [UserService],
        }).compile();

        userService = module.get(UserService);
        userController = module.get(UserController);
    });

    describe('findAll', () => {
        it('should return an array of users', async () => {
            const result = ['test'];
            jest.spyOn(userService, 'findAll').mockImplementation(() => result);

            expect(await userController.findAll()).toBe(result);
        });
    });
});
github TeamHive / nestjs-seed / src / app / modules / users / user.controller.spec.ts View on Github external
import { Test } from '@nestjs/testing';
import { UserController } from './user.controller';
import { UserService } from './user.service';
import {jest, describe, beforeEach, it, expect} from 'jest';

describe('UserController', () => {
    let userController: UserController;
    let userService: UserService;

    beforeEach(async () => {
        const module = await Test.createTestingModule({
            controllers: [UserController],
            components: [UserService],
        }).compile();

        userService = module.get(UserService);
        userController = module.get(UserController);
    });

    describe('findAll', () => {
        it('should return an array of users', async () => {
            const result = ['test'];