Skip to content

Add testing for application (backend, frontend, end2end)#270

Merged
alex-anakin merged 44 commits intohackforla:developmentfrom
nickbeaird:add_frontend_testing
Aug 28, 2020
Merged

Add testing for application (backend, frontend, end2end)#270
alex-anakin merged 44 commits intohackforla:developmentfrom
nickbeaird:add_frontend_testing

Conversation

@nickbeaird
Copy link
Contributor

@nickbeaird nickbeaird commented Aug 25, 2020

Adds in frontend testing for the application. This branch was branched from #264.

Overview:
Our application is in some dire need of some repeatability and testing is just the thing to remedy this. The goal of this branch started with getting our unit tests working again. It then moved into a discussion of what would help the team, which came up as adding something like Cypress. In all, this branch makes things much more repeatable and tested!

Acceptance Criteria:
[x] We have working Jest tests in the frontend
[x] We have working Jest tests in the backend
[x] We have a working end-2-end test suite (likely Cypress)
[x] Make sure that all test runners are working as expected.
[x] Configurable environment variables
[x] Update the README and relevant end documentation.

Setup & Verification Steps:

  1. Pull my branch locally
  • Please verify that the changes have been made by verifying that you have a "backend" and "cypress" directory
  1. Move your .env file at the root directory to the backend directory

  2. Add the below variables to your backend/.env file
    BACKEND_PORT=YOUR_DESIRED_PORT
    REACT_APP_PROXY=http://localhost:${BACKEND_PORT}
    SLACK_OAUTH_TOKEN=ASK_NICK_FOR_HIS?
    SLACK_BOT_TOKEN=ASK_NICK_FOR_HIS?
    SLACK_TEAM_ID=ASK_NICK_FOR_HIS?
    SLACK_CHANNEL_ID=ASK_NICK_FOR_HIS?
    SLACK_CLIENT_ID=ASK_NICK_FOR_HIS?
    SLACK_CLIENT_SECRET=ASK_NICK_FOR_HIS?
    SLACK_SIGNING_SECRET=ASK_NICK_FOR_HIS?

  3. Add the below variables to your client/.env file
    CLIENT_PORT=YOUR_DESIRED_PORT
    CLIENT_URL=http://localhost:${CLIENT_PORT}

  4. Delete all of your package.json file and nod_modules directories

  5. Run yarn install in the root, backend, and client directories.

  • cd root && yarn install
  • cd client && yarn install
  • cd ../backend && yarn install
  1. Navigate to the root directory
  • cd ..
  1. Run all the tests with npm run test:all

The above should have a fully functional running sets of test suites

Moving the instantiation of the server away from the application itself
allows us to import the express app as a moodule and test it. This keeps
us from actually spinning up a server instance on every import.
The slack app is starting every time the application is initialized,
which is causing the tests to be unable to close. This work will be
refactored out here soon.
These test cases showcase being able to write unit test and integration
tests using the database, models, and api.
@nickbeaird nickbeaird requested a review from alex-anakin August 25, 2020 17:11
@nickbeaird nickbeaird linked an issue Aug 25, 2020 that may be closed by this pull request
@nickbeaird nickbeaird changed the title Add frontend testing Add testing for application (backend, frontend, end2end) Aug 25, 2020
@alex-anakin alex-anakin merged commit 2dd5ac3 into hackforla:development Aug 28, 2020
@nickbeaird nickbeaird deleted the add_frontend_testing branch August 28, 2020 21:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Spike: Frontend unit and end-2-end testing

2 participants