-
Notifications
You must be signed in to change notification settings - Fork 136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test service with third party library #183
Comments
I am away for a couple of weeks, will reply on my return.
…On 30 Nov 2016 02:54, "EugeneSnihovsky" ***@***.***> wrote:
Hi. Thanks again for your repo. It is very useful and saves time for me.
Can you help me, please, to test service with third party library
(pouchDB)?
pouchDB has typings and it installed in ***@***.***/pouchDB
App works correct, but when I try to test service with PouchDB I receive
an error:
TypeError: pouchdb_1.default is not a constructor
And console.log show in terminal, that PouchDB is undefined. I think that
test missing typings for pouchDB, but can't figure out how to include it
correctly.
Service example:
'use strict';
import PouchDB from 'pouchdb';import quickSearch from 'pouchdb-quick-search';import PouchDbFind from 'pouchdb-find';
PouchDB.plugin(quickSearch);PouchDB.plugin(PouchDbFind);
import { Injectable } from ***@***.***/core';import { CONSTANTS } from '../../constants';
@Injectable()export class PouchDbService {
private animalsDb: any = new PouchDB(CONSTANTS.dataBaseName); // this line throw error
private searchFields: string[] = ['DE_Name', 'EN_Name'];
public search(query: string): Promise<any> {
return this.animalsDb.search({
query: query,
include_docs: true,
mm: '50%',
fields: this.searchFields
});
}
}
I already ask it on ionic forum, but topic about tests has no action for a
long time. I would be glad of any help. Thanks in advance.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#183>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AG5tSA0WZsVZ_sYHtYhNgZmZozLbCbGAks5rDHTdgaJpZM4K_VzM>
.
|
I'm not sure why you should get that error. I am testing pouch DB in a closed source project fine. However I have mocked pouch and initialise it a separate function so I spy and stub out when testing. A good example of this is StorageService:
This issue #169 discusses the concept a bit. However, I don't see how this would resolve the typings issue. IIRC, the typings for pouch were pretty fiddly? Is your project open source (can I clone and replicate the issue)? |
Closing in favour or #191 |
@EugeneSnihovsky Did you find a solution? Thanks |
Hi. Thanks again for your repo. It is very useful and saves time for me.
Can you help me, please, to test service with third party library (pouchDB)?
pouchDB has typings and it installed in node_modules/@types/pouchDB
App works correct, but when I try to test service with PouchDB I receive an error:
And console.log show in terminal, that PouchDB is undefined. I think that test missing typings for pouchDB, but can't figure out how to include it correctly.
Service example:
I already ask it on ionic forum, but topic about tests has no action for a long time. I would be glad of any help. Thanks in advance.
The text was updated successfully, but these errors were encountered: