Ravi Srinivasan
2019-02-13 015fee66acec75dbb6e5b7d9a1a0c634b27ad97d
exercises/3-revenge-of-the-automated-testing/README.md
@@ -14,7 +14,7 @@
The TDD cycle can be illustrated with the following diagram:
![TDD-diagram](../images/exercise3/TDD-lifecycle.jpg)
![TDD-diagram](../images/exercise3/TDD_Lifecycle.png)
### The TDD Cycle
@@ -119,10 +119,10 @@
4. Repeat the same process for `todolist-api` and verify that all the tests run. If you have an ExpressJS server already running from previous exercise; you should kill it before running the tests. The `mocha` test suite will launch a dev server for running the tests. There are 2 API test files: `todolist-api/server/api/todo/todo.spec.js` & `todolist-api/server/mocks/mock-routes.spec.js` for our API and the Mocks server. Remember to start the `mongo` container before running the tests
```bash
npm run mongo:start
cd todolist-api
```
```bash
cd todolist-api
npm run mongo:start
```
```bash
npm run test
@@ -412,6 +412,19 @@
npm run test -- --watch
```
> NOTE: You may see an `ENOSPC` error on Linux systems like the following:
```bash
ERROR jest exited with code 1.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! todolist-fe@1.0.0 test: `vue-cli-service test "--watch"`
npm ERR! Exit status 1
```
To fix this error, run the following command:
```bash
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
```
3. All the tests should be passing when we begin. If `No tests found related to files changed since last commit` is on show; hit `a` on the terminal to re-run `all` tests.
![rerun-all](../images/exercise3/rerun-all.png)
@@ -664,7 +677,24 @@
    ![if-e2e-step3a](../images/exercise3/if-e2e-step3a.png)
6.  Write the following test code. The pauses allow for the body of the page to render the todo list before exercising the test code:
```javascript
module.exports = {
    "Testing important flag setting": browser => {
      browser
        .url(process.env.VUE_DEV_SERVER_URL + '/#/todo')
        .waitForElementVisible("body", 5000)
        .pause(5000)
        .click('#clear-all')
        .pause(2000)
        .setValue('input',['set a todo',browser.Keys.ENTER])
        .pause(2000)
        .assert.elementPresent(".important-flag")
        .assert.elementNotPresent(".red-flag")
        .click('.important-flag')
        .end();
    }
  };
```
    <!-- ![if-e2e-step4](../images/exercise3/if-e2e-step4.png) -->
    ![if-e2e-step4](../images/exercise3/e2e-code-listing-full.jpg)