4.0.0 • Published 2 years ago

@zthun/works.jest v4.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Description

This package extends upon jest to add additional methods for mocking. It also adds some common assertions found throughout @zthun scoped projects.

Installation

# NPM
npm install @zthun/works.jest
# Yarn
yarn add @zthun/works.jest

Usage

The most useful feature in this package is going to be the createMocked method which should feel familiar to those who used jasmine for a long time to do unit tests. It's the equivalent of the jasmine.createSpyObj(...) method.

import { createMocked } from '@zthun/works.jest';

describe('My object with services.', () => {
  let service: jest.Mocked<IMyService>;

  beforeEach(() => {
    service = createMocked<IMyService>(['get', 'put']);

    service.get.mockReturnValue('You got it.');
  });

  it('should mock the service.', () => {
    // Arrange
    const target = service;
    // Act
    const actual = service.get();
    // Assert
    expect(actual).toEqual('You got it.');
  });
});

Most other methods deal with common assertions made throughout @zthun scoped projects, especially those which test builder objects and getter/setter properties. See the documentation for each individual method to see if any would apply to your specific requirements.

4.0.0

2 years ago

3.0.2

2 years ago

3.0.0

2 years ago

2.1.0

2 years ago

2.0.0

2 years ago

1.0.0

3 years ago

1.0.0-29

3 years ago

1.0.0-26

3 years ago

1.0.0-25

3 years ago

1.0.0-24

3 years ago

1.0.0-22

3 years ago

1.0.0-17

4 years ago

1.0.0-15

4 years ago

1.0.0-7

4 years ago

1.0.0-6

4 years ago