Robert Schäfer a819d6353a Fix probably randomly failing cypress test
@mattwr18 @ulfgebhardt @tirokk @appinteractive @ogerly

I think I just fixed a randomly failing test (so-called "flaky" test).
After an update of `neo4j-graphql-js` I wondered why the
`TagsAndCategories.feature` test failed consistently. It turns out the
table that you can see in the test is ordered by the "Users" column:

|   | Name      | Users  | Posts    |
| 1 | Democracy | 2      | 3        |
| 2 | Ecology   | 1      | 1        |
| 3 | Nature    | 1      | 2        |

So there is a tie between row 2 and row 3. It seems that on version
2.4.0 the backend would return those rows in arbitrary order and now it
returns them in a deterministic order, thus failing the test every time.

Therefore I changed the test setup and I believe this should also make
the build more robust now.
2019-05-17 00:09:54 +02:00
..
2019-03-21 02:11:35 +01:00
2019-03-21 02:11:35 +01:00
2019-05-07 00:51:18 +02:00

End-to-End Testing

Configure cypress

First, you have to tell cypress how to connect to your local neo4j database among other things. You can copy our template configuration and change the new file according to your needs.

Make sure you are at the root level of the project. Then:

# in the top level folder Human-Connection/
$ cp cypress.env.template.json cypress.env.json

Run Tests

To run the tests, do this:

# in the top level folder Human-Connection/
$ yarn cypress:setup

After verifying that there are no errors with the servers starting, open another tab in your terminal and run the following command:

$ yarn cypress:run

Console output after running cypress test

After the test runs, you will also get some video footage of the test run which you can then analyse in more detail.

Open Interactive Test Console

If you are like me, you might want to see some visual output. The interactive cypress environment also helps at debugging your tests, you can even time travel between individual steps and see the exact state of the app.

To use this feature, you will still run the yarn cypress:setup above, but instead of yarn cypress:run open another tab in your terminal and run the following command:

$ yarn cypress:open

Interactive Cypress Environment

Write some Tests

Check out the Cypress documentation for further information on how to write tests: https://docs.cypress.io/guides/getting-started/writing-your-first-test.html#Write-a-simple-test