Tomas Petricek
email: t.petricek@kent.ac.uk
twitter: @tomaspetricek
office: S129A
You can update web application instantly
You rarely have full control of all code you use
Development of a system is never done
Modern tools have complex multi-layer structure
Can you fix mistakes after product "release"?
Windows 95
Discard all your floppies if you notice early
Tell customers to return to the shop for a fix
Facebook, modern start-ups and others
Do multiple "releases" per day
Monitoring to avoid big failures
Small issues can be corrected in minutes
Do you control all the code your system runs?
Leftpad fiasco
11 line helper removed from NPM, breaking thousands of packages the whole world uses
How complex is your infrastructure?
UNIX on PDP-11 (circa 1970)
You can read all code the system runs
Tool is just a C file that you compile & run
Modern JavaScript
web development
Babel to compile new JavaScript to JavaScript
NPM to find packages
for everything you need
WebPack to combine source files and optimize
What is extreme programming
Tools and practices of XP
"If you get these 12 things right, you’ll have a disciplined team that can consistently deliver" (selection)
Your master
branch builds reproducibly
Everything also builds on a clean machine
All your tests run automatically and pass
Continuous integration tools help with this!
Code and tests - your actual code such as
test
, bot.js
and index.html
Dependency management - NPM package info package.json
and version lock file yarn.lock
Build configuration - build scripts in package.json
and
Webpack server and build config webpack.config.js
Continuous integration - tool configuration .travis.yml
and
related commands in package.json
Code and tests - writing and running tests
Dependency management - getting versions right
Build configuration - build and run with one command
Continuous integration - ensure reproducibility
Package dependencies
1.0.0
major, minor, revisionWhy is choosing versions hard
Solving version hell with lock files and the Yarn for JavaScript
Give your dependencies
Things you directly need
Solving version hell with lock files and the Yarn for JavaScript
Give your dependencies
Things you directly need
Auto-generate lock file
Exact versions including transitive dependencies
Build with one command
Makefile
in UNIX worldBuilding in JavaScript world
scripts
section in package.json
yarn build
, yarn test
etc.Forms of feedback when coding
Webpack and Webpack dev server
Tests for ensuring quality
Tests as a feedback mechanism
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: |
|
Writing JavaScript tests with Mocha
You describe
logic with tests written using it
notation
Run tests from terminal using
the mocha
tool
Unit tests are just one, easy to automate kind
How to structure code to make testing easy?
How to test not just functions, but user interfaces
Property testing to specify more than one case
What you need to use CI
Continuous integration servers
Continuous integration support on GitHub
Runs build and tests every time you git push
Runs build and tests for every pull request
Shows warning when
PR build fails
Beyond simple CI
Device testing
for mobile applications
Continuous deployment to directly release new version of the product
Changing context of software development
Release frequency and system complexity
Extreme programming: feedback and continuous process
Modern (JavaScript) project infrastructure
One command build to run, test and build
Dependency management, versioning and lock files
Testing and continuous integration tools
Tests for ensuring quality and tests for feedback
Running build automatically with CI systems
What you should remember from this lecture
Tomas Petricek
t.petricek@kent.ac.uk | @tomaspetricek
Papers and articles
Libraries and tools