1.1.0 • Published 3 years ago

jest-ts-tocompile v1.1.0

Weekly downloads
-
License
GPL-3.0
Repository
github
Last release
3 years ago

jes-ts-tocompile

Custom Jest matcher for testing if a typescript file compiles.

Installation

  1. Install with npm
npm i jest-ts-tocompile
  1. Import and install jest-ts-tocompile in your jest setup file.
const toCompile = require('jest-ts-tocompile');

toCompile.install();

With TypeScript

When using typescript, you need to add the jest type augmentations to your project. In order to do this, create a jest.d.ts file in your project root and add the following code:

declare namespace jest {
  interface Matchers<R> {
    toCompile(): R;
  }
}

Usage

You can call expect passing the file path of the typescript file to test and then call .toCompile() to test if the file compiles.

import path from 'path';

describe('example files are correct', () => {
   it('should compile', () => {
      expect(path.join(__dirname, './example.ts')).toCompile();
   });
})
1.1.0

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago