abritinthebay / jest-tobetype

A jest matcher that allows you to test the expected type of a value
MIT License
29 stars 6 forks source link

Possible to use with TypeScript? #17

Open adams-family opened 4 years ago

adams-family commented 4 years ago

I've been using jest-tobetype in my project and I love it. Recently I was forced to convert my project to TypeScript (due to NRWL integration) and I cannot make jest-tobetype work since then :(

My run.test.ts file looks like this:

import {toBeType} from "jest-tobetype";
expect.extend(toBeType);

describe('Test API', () => {
    it('Should return an object', async () => {
        const { status, body } = await request(app).get('/');
        expect(status).toEqual(200)
        expect(body).toBeType('object')
    })
})

However during runtime I get the following error:

error TS2339: Property 'toBeType' does not exist on type 'JestMatchersShape<Matchers<void, any>, Matchers<Promise<void>, any>>'

Any ideas? Maybe I'm missing the obvious...

abhijithvijayan-kubric commented 3 years ago

no TS support yet!

abritinthebay commented 3 years ago

This appears to be a TS issue (and would happen with any extension to Jest I think).

Suggestions are welcome to what the fix would be.

abritinthebay commented 3 years ago

Just merged something that SHOULD fix this, but will have to wait for a release to see (as I don't use this in a TS toolchain)