DAO-job-board icon indicating copy to clipboard operation
DAO-job-board copied to clipboard

Add tests

Open carlomigueldy opened this issue 3 years ago • 12 comments

TL;DR: If you just wanna do something you can add tests and we'll add that to CI.

Overview

This isn't a priority right now but if someone wants to take it and add automated tests then that would be very awesome. I have no specific tests to target but if you can come up with test cases then that's much appreciated 🤝

carlomigueldy avatar Dec 01 '21 23:12 carlomigueldy

I’m no test expert though I think we should be implementing them with the amount of data being thrown around, added with the upcoming token and amount of traffic expected to be flooding the job board.

We can put it up to vote but for me it should be considered.

PBillingsby avatar Dec 03 '21 19:12 PBillingsby

I’m no test expert though I think we should be implementing them with the amount of data being thrown around, added with the upcoming token and amount of traffic expected to be flooding the job board.

We can put it up to vote but for me it should be considered.

Yo that sounds good. Can you elaborate more on this?

carlomigueldy avatar Dec 04 '21 10:12 carlomigueldy

We should be implementing at bare minimum some unit testing. With the amount of people, and possibly bots using the site, the database is at risk of bad data being passed. Writing Jest tests on stateful components like the forms will allow us, in an easier way, to check if bad data is being persisted. It will also give us a better chance at identifying bugs and where particular blocks of code are breaking.

Jest resources: https://jestjs.io/docs/getting-started https://blog.logrocket.com/testing-typescript-apps-using-jest/ https://itnext.io/testing-with-jest-in-typescript-cc1cd0095421

Basic example Jest test:

import { add } from "../src/calc";
describe("test add function", () => {
  it("should return 15 for add(10,5)", () => {
    expect(add(10, 5)).toBe(15);
  });
it("should return 5 for add(2,3)", () => {
    expect(add(2, 3)).toBe(5);
  });
});

PBillingsby avatar Dec 04 '21 13:12 PBillingsby

Definitely think we need some more opinions on this as I am not the most experienced tester.

PBillingsby avatar Dec 04 '21 13:12 PBillingsby

Yo very awesome! Thanks for the details @PBillingsby and yeah unit tests would definitely help us guard from spams, we can write tons of scenarios that we can think of.

Definitely think we need some more opinions on this as I am not the most experienced tester.

Agreed, I've only be unit testing with Jest for like 3-4 months so I'm definitely not that experienced tester either. But I do know who's a very good at it in fact a mentor, I'll reach out to him :)

carlomigueldy avatar Dec 04 '21 23:12 carlomigueldy

Might I suggest that we have an accessibility tool like jest-axe and including even just the basic toHaveNoViolations() check to catch the very obvious a11y issues that people tend to miss?

krames12 avatar Dec 12 '21 02:12 krames12

Might I suggest that we have an accessibility tool like jest-axe and including even just the basic toHaveNoViolations() check to catch the very obvious a11y issues that people tend to miss?

Yo please do, we'd love to have that. :)

carlomigueldy avatar Dec 12 '21 02:12 carlomigueldy

Once I'm done with #115, I wouldn't mind picking this up and adding even just some basic unit tests where possible. Would it be safe to assume it would be best to submit a PR for the initial testing-library/react setup + a basic test to prove it's working and then a separate PR for each section of the project?

krames12 avatar Dec 13 '21 01:12 krames12

Once I'm done with #115, I wouldn't mind picking this up and adding even just some basic unit tests where possible. Would it be safe to assume it would be best to submit a PR for the initial testing-library/react setup + a basic test to prove it's working and then a separate PR for each section of the project?

Yes we would love to have that as well! Please do so :)

carlomigueldy avatar Dec 13 '21 04:12 carlomigueldy

@carlomigueldy Last question for the moment. I'm assuming this is just for unit testing and not both unit testing and end to end tests with something like Cypress, correct? If it does encompass both, I think we should make an issue to discuss what type of testing would need to be done there that isn't covered with unit tests.

krames12 avatar Dec 14 '21 02:12 krames12

At a bare minimum, there needs to be unit tests. Integration tests are always helpful, too, ofc.

frankTurtle avatar Dec 14 '21 03:12 frankTurtle

I'd love to have tests for the project, but we probably need to add them once we have the MVP or before launching it, so adding a for-later tag to this

4gnle avatar Dec 27 '21 16:12 4gnle