odota/web

Unit tests

mike-robertson opened this issue · 19 comments

We need to add unit tests since the code base is becoming quite large, and since we all have our own 'domains' that we work on, changes to components across domains can cause subtle bugs (if we don't have unit tests). I think that the #1 priority after completing MVP should be to go back and add useful unit tests for everything since we don't have any dedicated QA contributors or QA process.

@mike-robertson: I'd love to work on this. I'm very much aligned to TDD and unit testing. Do you have a testing framework in mind? I've used mocha, chai and enzyme to test components. I also had a really bad time trying to use Jest.

odota/core uses mocha. I think it'd be helpful to use the same one on both.

I agree that mocha/chai/enzyme is the easiest testing 'stack' to use with react.

We also need e2e testing, http://nightwatchjs.org/

https://www.browserstack.com/ is another option. I've never tried setting this kind of thing up, so feel free to tackle this if you have any experience.

@howardchung: As far as I understand, browserstack is a paid service, do we have enough bandwidth to use it?
@dartharaknus: nightwatchjs looks pretty cool. Have you used it? Looking forward to work with it

They are free for open source projects (need to submit a request):
https://www.browserstack.com/pricing

@Roshanjossey are you still interested in improving test coverage? @mike-robertson laid out the foundation and wrote a couple of quick tests, but the majority of components still don't have them.

@howardchung, @mike-robertson, I'm sorry I couldn't take a look at this earlier. I'll get started on this.

How should I divide work? I'd like to submit PRs in smaller chunks rather than doing it all at once

Maybe just add one test for one component at a time.

I wrote on discord, but might be better to say it here. We should probably be using selenium as our web driver now that browserstack is looking to support us https://www.browserstack.com/automate

Tb0 commented

Hello everyone,
I am a QA engineer Dota2 fan, and I would be happy to help you on automating End to End tests using the selenium webdriver in JS. That would be the easiest way to integrate E2E tests to the current stack of technology. Ping me if you are interested in :) @howardchung

@Tb0 would love to see E2E tests added! @masad-frost set up an account for us on BrowserStack, let me know if you need access to that.

Also apparently Chrome 59 has a headless mode which is supposed to make CI testing easier.

Now that the project is a standard create-react-app project you can use their testing convention, based on Jest:

https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#running-tests

@dartharaknus suggests https://www.chromaticqa.com/ for component testing

I suggest use puppeteer, but it's not unit-test its E2E test. You can compare screenshots like in Codesandbox

I think that's more #1596

We have a few e2e tests. . . not sure we'll get more than that but happy to accept contributions