What-Should-I-Eat / WSIE

Drexel University MSSE Capstone Project
http://whatshouldieat.org
2 stars 2 forks source link

Wk 4 - Start looking at docs for JS testing (everyone if you have time) #60

Closed torieee closed 7 months ago

torieee commented 8 months ago

Some resources (I've never done this and these look pretty basic but similar in structure to java tests). Note that we are using Node.js specifically. If you find something you think will work, put it in the comments below.

https://www.freecodecamp.org/news/how-to-start-unit-testing-javascript/ https://www.lambdatest.com/learning-hub/javascript-unit-testing https://www.testim.io/blog/node-js-unit-testing-get-started-quickly-with-examples/

nicksonsini97 commented 8 months ago

Also don't have experience with Javascript testing, but I came across Jest framework. Have some links below, going to mess with it the next few days but definitely not married to it if there's better options! It looks like the unit testing and code coverage report is pretty easy

https://jestjs.io/docs/getting-started# https://www.youtube.com/watch?v=FgnxcUQ5vho https://www.youtube.com/watch?v=uH5doKI8gd8

Added a branch if anyone wants to mess around with it. Only did a super basic test case so far. To run it, just run "npm test"

** update ** I think the API testing also needs SuperTest for Jest. I have it installed and an attempted test created in jestTest branch but haven't gotten it working yet. Some docs I tried were: https://circleci.com/blog/api-testing-with-jest/#creating-your-space-api https://www.makeuseof.com/express-apis-jest-test/ https://www.freecodecamp.org/news/end-point-testing/

emmeline2 commented 8 months ago

I saw Jest as a good framework as well. I tried out Jasmine just to see what it was like on branch: test_using_jasmine . Jasmine seems pretty similar to me, but I think you need to add another tool to get code coverage ( karma or grunt) so maybe it makes sense to go with Jest just to have everything all in one tool.

nicksonsini97 commented 8 months ago

Screen Shot 2024-02-04 at 9 02 13 AM I haven't tried it on any server endpoints yet, and I gotta figure out how to get around the event.preventDefault() for testing some of the front end stuff but this is what it looks like from npm test. Again if we see something better that's all good too!