DaniJG / sinon-mongo

A Node library that simplifies writing unit tests using sinon for mocking code using the MongoDB client.
MIT License
4 stars 5 forks source link

Issue about declaration file #8

Closed vovalexeev closed 3 years ago

vovalexeev commented 3 years ago

Hello!

I am a beginner in writing unit tests for mongoDB and I'd like to use sinon-mongo for testing my app. I've installed it (npm install sinon-mongo) and added "const sinon = require('sinon'); require('sinon-mongo');". But VS Code shows message about require('sinon-mongo') string:

Could not find a declaration file for module 'sinon-mongo'. '.../node_modules/sinon-mongo/index.js' implicitly has an 'any' type. Try npm i --save-dev @types/sinon-mongo if it exists or add a new declaration (.d.ts) file containing declare module 'sinon-mongo';

I have two questions: 1) Is it okay for me? 2) Why message contains .ts extension, but my project doesn't contain any .ts files?

DaniJG commented 3 years ago

Hi @vovalexeev happy to see you got it sorted!

I am not a typescript user myself, but I assume either your project was setup as a typescript project, or it was caused due to some VSCode extension? Sadly since I am not a typescript user myself, I haven't really added typings to the library!

Let me know if you need a hand using the library or with unit tests in general :)

PS. in case you have not seen them, the tests used to verify the library itself might be a decent set of examples on how to use it: https://github.com/DaniJG/sinon-mongo/tree/master/test