Skip to content

Commit

Permalink
Chapter 5 updates.
Browse files Browse the repository at this point in the history
  • Loading branch information
EthanRBrown committed Jan 13, 2020
1 parent 2a1c079 commit 10e9b7b
Show file tree
Hide file tree
Showing 5 changed files with 1,496 additions and 846 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@ The [Chapter 3 Examples](ch03/README.md) demonstrate a simple, minimal web serve
### Chapter 4

The [Chapter 4 Example](ch03/README.md) take the "fortune cookie" functionality deveoped in Chapter 3, and implement it as a Node module.

### Chapter 5

The [Chapter 5 Example](ch03/README.md) demonstrates unit testing with Jest, integration testing with Jest and Puppeteer, and linting with ESLint.
50 changes: 50 additions & 0 deletions ch05/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Chapter 5 Examples - Web Development with Node and Express, 2nd Edition

## QA: Unit Testing, Integration Testing, and Linting

This chapter covers unit testing, integration testing, and linting. There is only one example that covers all of these topics, which have all been configured according to the content in Chapter 5.


### Setup

The example in this chapter has Node module dependencies (`express` and `express-handlebars`). These dependencies are listed in the _package.json_ file. However, when you first clone this repo, you won't have them installed (_package.json_ is simply a manifest). To install them, simply run:

```
npm install
```

### Running

Minimal example; uses Express, but doesn't do very much. To run:

```
node 00-meadowlark
```

Then visit _http://localhost:3000_ in your browser.

### Running Tests (Unit and Integration)

To run unit tests (see _lib/__tests__/handlers.test.js_) and integration tests (see _integration-tests/basic-navigation.test.js_):

```
npm test
```

To see how tests are configured, look at the `test` script in _package.json_.

### Test Coverage

To see test coverage, run:

```
npm test -- --coverage
```

### Linting

To lint the application, run:

```
npm lint
```
3 changes: 3 additions & 0 deletions ch05/meadowlark.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ app.get('/', handlers.home)

app.get('/about', handlers.about)

// custom 404 page
app.use(handlers.notFound)

// custom 500 page
app.use(handlers.serverError)

if(require.main === module) {
Expand Down
Loading

0 comments on commit 10e9b7b

Please sign in to comment.