jehy / telegram-test-api

Simple implimentation of telegram API which can be used for testing telegram bots
MIT License
98 stars 24 forks source link

Compatability with jest #13

Closed kiwikern closed 5 years ago

kiwikern commented 5 years ago

When I import 'telegram-test-api' in a jest test it will fail with Unable to expose method "then".

import * as TelegramServer from 'telegram-test-api';

Apparently, this is because jest is not compatible with request-promise, see this issue.

As a workaround, you can mock out request-promise before the import, but then of course the requests won't work.

jest.mock('request-promise-native');
jehy commented 5 years ago

Could you provide me with an example and with full stack trace? I just replaced mocha with jest for package's internal tests and everything went fine.

jehy commented 5 years ago

By the way, try version 2.0.0 - I just published it. It has axios instead of request-promise as a dependency, so it can help.

kiwikern commented 5 years ago

Great! :-) Thank you!