balderdashy / sails

Realtime MVC Framework for Node.js
https://sailsjs.com
MIT License
22.84k stars 1.95k forks source link

Update and improve the documentation on Testing #7307

Open alex-marquette opened 11 months ago

alex-marquette commented 11 months ago

Node version: Sails version (sails): ORM hook version (sails-hook-orm): Sockets hook version (sails-hook-sockets): Organics hook version (sails-hook-organics): Grunt hook version (sails-hook-grunt): Uploads hook version (sails-hook-uploads): DB adapter & version (e.g. sails-mysql@5.55.5): Skipper adapter & version (e.g. skipper-s3@5.55.5):


Basically, the title. After going through the course on Platzi, looking at the Ration.io source code and the official documentation I don't think I ever really had a decent testing setup run the way it probably was expected to for this framework. The closest I got was following this blog by Kevin, https://blog.sailscasts.com/testing-sails-applications-with-mocha-and-supertest and that blog post is for a Sails JS API with no front-end option set.

Looking specifically at the official documentation on the website, if you need to test with a front-end there's no mention of disabling the CSRF in the test environment or creating a fake endpoint to get a cookie and the CSRF as shown in the ration.io source code. So if you are brand new, you can end up with 403 or 401 on a 200 request because of not having a cookie or the CSRF token present both of which aren't mentioned in the official documentation on the website. There are also a lot of baked assumptions in the documentation themselves which can make it hard for anyone starting out with the framework to figure out what is really happening behind the scenes in the testing environment. At bare minimum the documentation should be able to provide a developer with a simple setup and be able to handle authenticating a user and doing something with that authenticated user (like viewing a restricted page) if they have the front-end generated for the application.

sailsbot commented 11 months ago

@alex-marquette Thanks for posting! We'll take a look as soon as possible.

In the mean time, there are a few ways you can help speed things along:

Please remember: never post in a public forum if you believe you've found a genuine security vulnerability. Instead, disclose it responsibly.

For help with questions about Sails, click here.

eashaw commented 11 months ago

Thanks for the suggestion/feedback @alex-marquette, I'll bring this up with the team when we meet next.

vr-varad commented 9 months ago

@eashaw can i work on it?

eashaw commented 8 months ago

@vr-varad Of course! We're always happy to take a look at PRs that improve the Sails documentation.