This package has been deprecated

Author message:

Moved to using 3rd party libraries

@zthun/works.jest
TypeScript icon, indicating that this package has built-in type declarations

4.0.0 • Public • Published

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.

Readme

Keywords

none

Package Sidebar

Install

npm i @zthun/works.jest

Weekly Downloads

1

Version

4.0.0

License

MIT

Unpacked Size

233 kB

Total Files

28

Last publish

Collaborators

  • zthun