feathersjs / docs

[MOVED] Legacy Feathers documentation
https://crow.docs.feathersjs.com/
MIT License
242 stars 532 forks source link

Comment: Writing tests (guides/basics/testing.md) #1481

Closed Barbapapazes closed 4 years ago

Barbapapazes commented 4 years ago

Comment/Problem

I think it could be nice to show how to test a class of a service. Because testing hook is is just testing function but classes are different.

In fact, to instantiate a class, we need to pass some options like the model, for mongoose adapter, and at the end, we call "super.created" (or any other methods). But this will call a method from adapter common which call the method from the mongoose adapter. It's very difficult to understand and I think that it could be a good think to explain it. Otherwise, I found no resources on internet. 😐

daffl commented 4 years ago

There is a section on how to test services at https://docs.feathersjs.com/guides/basics/testing.html#testing-services. You do not need to instantiate them yourself, you just pull in the application object and run the test against the already registered and instantiated service.