colinrobertbrooks / testing-javascript-applications-demo

A demo app with static analysis and unit/integration/end-to-end tests 🧪

Home Page:https://colinrobertbrooks.github.io/blog/testing-javascript-applications/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Testing Javascript Applications Demo

A demo app with static analysis and unit/integration/end-to-end tests. Read more about it here.

Build Status Codecov Coverage

System Requirements

  • git v2.14.1 or greater
  • node v8.9.4 or greater
  • npm v5.6.0 or greater

Setup

git clone https://github.com/colinrcummings/testing-javascript-applications-demo.git
cd testing-javascript-applications-demo
npm run setup

About the app

This app has a home page, a login page and a series of feature pages (Feature 1 and Feature 2) for authorized users. Users can be created, updated and destroyed by admin users on the Manage Users page.

Running the app

Development

Optimized for DX.

npm run db:reset:dev
npm run start:dev

Visit localhost:3000; login with username "admin" and password "password".

Test

Optimized for end-to-end testing (see below).

npm run db:reset:test
npm run build:test
npm run start:test

Visit localhost:3000; login with username "cypress" and password "password".

Production

Optimized for UX.

npm run db:init
npm run build
npm start

Visit localhost:80; login with username "admin" and password "password".

Running tests

Scripts included in the precommit and validate scripts are indicated below.

Static Analysis

Run eslint against the codebase for a list of exceptions (staged files are checked in the precommit script; all files are checked in the validate script):

npm run lint

Run prettier against the codebase for a list of exceptions (staged files are checked in the precommit script; all files are checked in the validate script):

npm run format:check

Run prettier against the codebase and automatically fix exceptions:

npm run format:fix

Unit & Integration

Run jest tests (included in the precommit script):

npm run test

Run jest tests in watch mode:

npm run test:watch

Run jest tests and generate code coverage via istanbul (included in the validate script):

npm run coverage

End-to-end

Run cypress tests in headless mode (included in the validate scripts):

npm run test:e2e

Run cypress tests in interactive mode:

test:e2e:interactive

Both commands reset the database, generate a build and start the server first.

About

A demo app with static analysis and unit/integration/end-to-end tests 🧪

https://colinrobertbrooks.github.io/blog/testing-javascript-applications/

License:MIT License


Languages

Language:JavaScript 94.2%Language:HTML 5.4%Language:CSS 0.3%Language:Shell 0.0%