SlideShare a Scribd company logo
Continuous Integration
for front-end JavaScript
Lars Thorup
ZeaLake Software Consulting


April, 2013
Who is Lars Thorup?

●   Software developer/architect
     ●   JavaScript, C#
     ●   Test Driven Development
     ●   Continuous Integration

●   Coach: Teaching agile and
    automated testing

●   Advisor: Assesses software
    projects and companies

●   Founder of ZeaLake
Continuous Integration
 Code                       CI-server                     Results
 function createBoard() {
   ...
 }                                      static analysis
                                                              errors

                                         test runner
 Tests
 test('createBoard', {
    ...                                                      coverage
                                   coverage analysis
 });


                                         minification      distributables
GruntJS
●   Command line             ●   Good support for
     ●   NodeJS                   ●   RequireJS
                                  ●   CoffeeScript
●   Static analysis
     ●   JSHint              ●   Lots of other plugins

●   Run tests in PhantomJS   ●   Popular and actively
     ●   QUnit                   developed
     ●   Jasmine
     ●   and others

●   Code Coverage
     ●   Istanbul
     ●   Blanket
src/test/code.test.js
 describe('durationInEnglish', function () {

       it('should return "now" when duration is 0', function () {
           expect(durationInEnglish(0)).toBe('now');
       });

       it('should return "x seconds ago" when ...', function () {
           var now = new Date(2013, 04, 19, 11, 00, 17);
           var then = new Date(2013, 04, 19, 11, 00, 00);
           expect(durationInEnglish(now - then)).toBe('17 seconds ago');
       })

 });
src/js/code.js

 function durationInEnglish(milliseconds) {
     var seconds = milliseconds / 1000;
     if(seconds === 0) {
         return 'now';
     } else if(seconds < 60) {
         return seconds + ' seconds ago';
     } else {
         return 'whenever';
     }
 }
package.json

 {
     "name": "gruntdemo",
     "version": "0.1.1-1",
     "devDependencies": {
         "grunt-cli": "0.1.6",
         "grunt": "0.4.1",
         "grunt-contrib-jshint": "~0.1.1",
         "grunt-contrib-jasmine": "0.4.1",
         "grunt-template-jasmine-istanbul": "0.2.0"
     }
 }



                              >npm install
Gruntfile.js

 module.exports = function (grunt) {
     var gruntConfig = {};

      // task definitions
      ...

      // grunt
      grunt.initConfig(gruntConfig);
 };
Gruntfile.js - jshint
 grunt.loadNpmTasks('grunt-contrib-jshint');
 gruntConfig.jshint = {
     all: [
         '*.js',
         'src/**/*.js'
     ]
 };




                                 >grunt jshint
                                 Running "jshint:all" (jshint) task
                                 >> 3 files lint free.
Gruntfile.js - jasmine
 grunt.loadNpmTasks('grunt-contrib-jasmine');
 gruntConfig.jasmine = {
     src: {
         src: [
             'src/js/**/*.js'
         ],
         options: {
             specs: 'src/test/**/*.test.js',
             junit: {
                 path: 'output/testresults'
             }
         }
     }                            >grunt jasmine:src
 };                               Running "jasmine:src" (jasmine) task
                                  Testing jasmine specs via phantom
                                  ..
                                  2 specs in 0.109s.
                                  >> 0 failures
Gruntfile.js - istanbul
gruntConfig.jasmine.istanbul = {
    src: gruntConfig.jasmine.src.src,
    options: {
        specs: gruntConfig.jasmine.src.options.specs,
        template: require('grunt-template-jasmine-istanbul'),
        templateOptions: {
            coverage: 'output/coverage/coverage.json',
            report: [
                {type: 'html', options: {dir: 'output/coverage'}},
                {type: 'text-summary'}
            ]
        }                 >grunt jasmine:istanbul
                          Running "jasmine:istanbul" (jasmine) task
    }
                          Testing jasmine specs via phantom
};
                          ..
                          ========== Coverage summary ===========
                          Statements    : 85.71% ( 6/7 )
                          Branches      : 75% ( 3/4 )
                          Functions     : 100% ( 1/1 )
                          Lines         : 85.71% ( 6/7 )
                          =======================================
Coverage report
Coverage details
Jenkins job
Jenkins report

More Related Content

What's hot (20)

Angular2 ecosystem
Angular2 ecosystemAngular2 ecosystem
Angular2 ecosystem
Kamil Lelonek
 
Introduction to Express and Grunt
Introduction to Express and GruntIntroduction to Express and Grunt
Introduction to Express and Grunt
Peter deHaan
 
Future of NodeJS
Future of NodeJSFuture of NodeJS
Future of NodeJS
Sébastien Pertus
 
Let s Enjoy Node.js
Let s Enjoy Node.jsLet s Enjoy Node.js
Let s Enjoy Node.js
Fred Chien
 
The SPDY Protocol
The SPDY ProtocolThe SPDY Protocol
The SPDY Protocol
Fabian Lange
 
Preprocessor Workflow with Grunt
Preprocessor Workflow with GruntPreprocessor Workflow with Grunt
Preprocessor Workflow with Grunt
Vlad Filippov
 
Running JavaScript Efficiently in a Java World
Running JavaScript Efficiently in a Java WorldRunning JavaScript Efficiently in a Java World
Running JavaScript Efficiently in a Java World
irbull
 
Asynchronous Module Definition (AMD)
Asynchronous Module Definition (AMD)Asynchronous Module Definition (AMD)
Asynchronous Module Definition (AMD)
xMartin12
 
Grunt and Bower
Grunt and BowerGrunt and Bower
Grunt and Bower
George Estebe
 
"How to Use Bazel to Manage Monorepos: The Grammarly Front-End Team’s Experie...
"How to Use Bazel to Manage Monorepos: The Grammarly Front-End Team’s Experie..."How to Use Bazel to Manage Monorepos: The Grammarly Front-End Team’s Experie...
"How to Use Bazel to Manage Monorepos: The Grammarly Front-End Team’s Experie...
Fwdays
 
Superfast Automated Web Testing with CasperJS & PhantomJS
Superfast Automated Web Testing with CasperJS & PhantomJS Superfast Automated Web Testing with CasperJS & PhantomJS
Superfast Automated Web Testing with CasperJS & PhantomJS
Hervé Vũ Roussel
 
Node js实践
Node js实践Node js实践
Node js实践
jay li
 
Java/Spring과 Node.js의 공존 시즌2
Java/Spring과 Node.js의 공존 시즌2Java/Spring과 Node.js의 공존 시즌2
Java/Spring과 Node.js의 공존 시즌2
동수 장
 
Fundamental of Node.JS - Internship Presentation - Week7
Fundamental of Node.JS - Internship Presentation - Week7Fundamental of Node.JS - Internship Presentation - Week7
Fundamental of Node.JS - Internship Presentation - Week7
Devang Garach
 
Роман Лютиков "Web Apps Performance & JavaScript Compilers"
Роман Лютиков "Web Apps Performance & JavaScript Compilers"Роман Лютиков "Web Apps Performance & JavaScript Compilers"
Роман Лютиков "Web Apps Performance & JavaScript Compilers"
Fwdays
 
Testing nodejs apps
Testing nodejs appsTesting nodejs apps
Testing nodejs apps
felipefsilva
 
Node4J: Running Node.js in a JavaWorld
Node4J: Running Node.js in a JavaWorldNode4J: Running Node.js in a JavaWorld
Node4J: Running Node.js in a JavaWorld
Ian Bull
 
Groovy Ecosystem - JFokus 2011 - Guillaume Laforge
Groovy Ecosystem - JFokus 2011 - Guillaume LaforgeGroovy Ecosystem - JFokus 2011 - Guillaume Laforge
Groovy Ecosystem - JFokus 2011 - Guillaume Laforge
Guillaume Laforge
 
Advanced front-end automation with npm scripts
Advanced front-end automation with npm scriptsAdvanced front-end automation with npm scripts
Advanced front-end automation with npm scripts
k88hudson
 
CasperJS
CasperJSCasperJS
CasperJS
LearningTech
 
Introduction to Express and Grunt
Introduction to Express and GruntIntroduction to Express and Grunt
Introduction to Express and Grunt
Peter deHaan
 
Let s Enjoy Node.js
Let s Enjoy Node.jsLet s Enjoy Node.js
Let s Enjoy Node.js
Fred Chien
 
Preprocessor Workflow with Grunt
Preprocessor Workflow with GruntPreprocessor Workflow with Grunt
Preprocessor Workflow with Grunt
Vlad Filippov
 
Running JavaScript Efficiently in a Java World
Running JavaScript Efficiently in a Java WorldRunning JavaScript Efficiently in a Java World
Running JavaScript Efficiently in a Java World
irbull
 
Asynchronous Module Definition (AMD)
Asynchronous Module Definition (AMD)Asynchronous Module Definition (AMD)
Asynchronous Module Definition (AMD)
xMartin12
 
"How to Use Bazel to Manage Monorepos: The Grammarly Front-End Team’s Experie...
"How to Use Bazel to Manage Monorepos: The Grammarly Front-End Team’s Experie..."How to Use Bazel to Manage Monorepos: The Grammarly Front-End Team’s Experie...
"How to Use Bazel to Manage Monorepos: The Grammarly Front-End Team’s Experie...
Fwdays
 
Superfast Automated Web Testing with CasperJS & PhantomJS
Superfast Automated Web Testing with CasperJS & PhantomJS Superfast Automated Web Testing with CasperJS & PhantomJS
Superfast Automated Web Testing with CasperJS & PhantomJS
Hervé Vũ Roussel
 
Node js实践
Node js实践Node js实践
Node js实践
jay li
 
Java/Spring과 Node.js의 공존 시즌2
Java/Spring과 Node.js의 공존 시즌2Java/Spring과 Node.js의 공존 시즌2
Java/Spring과 Node.js의 공존 시즌2
동수 장
 
Fundamental of Node.JS - Internship Presentation - Week7
Fundamental of Node.JS - Internship Presentation - Week7Fundamental of Node.JS - Internship Presentation - Week7
Fundamental of Node.JS - Internship Presentation - Week7
Devang Garach
 
Роман Лютиков "Web Apps Performance & JavaScript Compilers"
Роман Лютиков "Web Apps Performance & JavaScript Compilers"Роман Лютиков "Web Apps Performance & JavaScript Compilers"
Роман Лютиков "Web Apps Performance & JavaScript Compilers"
Fwdays
 
Testing nodejs apps
Testing nodejs appsTesting nodejs apps
Testing nodejs apps
felipefsilva
 
Node4J: Running Node.js in a JavaWorld
Node4J: Running Node.js in a JavaWorldNode4J: Running Node.js in a JavaWorld
Node4J: Running Node.js in a JavaWorld
Ian Bull
 
Groovy Ecosystem - JFokus 2011 - Guillaume Laforge
Groovy Ecosystem - JFokus 2011 - Guillaume LaforgeGroovy Ecosystem - JFokus 2011 - Guillaume Laforge
Groovy Ecosystem - JFokus 2011 - Guillaume Laforge
Guillaume Laforge
 
Advanced front-end automation with npm scripts
Advanced front-end automation with npm scriptsAdvanced front-end automation with npm scripts
Advanced front-end automation with npm scripts
k88hudson
 

Similar to Continuous Integration for front-end JavaScript (20)

Let Grunt do the work, focus on the fun!
Let Grunt do the work, focus on the fun!Let Grunt do the work, focus on the fun!
Let Grunt do the work, focus on the fun!
Dirk Ginader
 
Grunt.js and Yeoman, Continous Integration
Grunt.js and Yeoman, Continous IntegrationGrunt.js and Yeoman, Continous Integration
Grunt.js and Yeoman, Continous Integration
David Amend
 
Javascript is your (Auto)mate
Javascript is your (Auto)mateJavascript is your (Auto)mate
Javascript is your (Auto)mate
Codemotion
 
Js tacktalk team dev js testing performance
Js tacktalk team dev js testing performanceJs tacktalk team dev js testing performance
Js tacktalk team dev js testing performance
Артем Захарченко
 
Ustream vs Legacy, It's never too late to start your fight! #Jsist 2014
Ustream vs Legacy, It's never too late to start your fight! #Jsist 2014Ustream vs Legacy, It's never too late to start your fight! #Jsist 2014
Ustream vs Legacy, It's never too late to start your fight! #Jsist 2014
Máté Nádasdi
 
Grunt Continuous Development of the Front End Tier
Grunt Continuous Development of the Front End TierGrunt Continuous Development of the Front End Tier
Grunt Continuous Development of the Front End Tier
Erick Brito
 
Let Grunt do the work, focus on the fun! [Open Web Camp 2013]
Let Grunt do the work, focus on the fun! [Open Web Camp 2013]Let Grunt do the work, focus on the fun! [Open Web Camp 2013]
Let Grunt do the work, focus on the fun! [Open Web Camp 2013]
Dirk Ginader
 
How do I write Testable Javascript so I can Test my CF API on Server and Client
How do I write Testable Javascript so I can Test my CF API on Server and ClientHow do I write Testable Javascript so I can Test my CF API on Server and Client
How do I write Testable Javascript so I can Test my CF API on Server and Client
Gavin Pickin
 
Zero-config JavaScript apps with RaveJS -- SVCC fall 2014
Zero-config JavaScript apps with RaveJS -- SVCC fall 2014Zero-config JavaScript apps with RaveJS -- SVCC fall 2014
Zero-config JavaScript apps with RaveJS -- SVCC fall 2014
John Hann
 
An Introduction to the World of Testing for Front-End Developers
An Introduction to the World of Testing for Front-End DevelopersAn Introduction to the World of Testing for Front-End Developers
An Introduction to the World of Testing for Front-End Developers
FITC
 
FITC Web Unleashed 2017 - Introduction to the World of Testing for Front-End ...
FITC Web Unleashed 2017 - Introduction to the World of Testing for Front-End ...FITC Web Unleashed 2017 - Introduction to the World of Testing for Front-End ...
FITC Web Unleashed 2017 - Introduction to the World of Testing for Front-End ...
Haris Mahmood
 
Get Gulping with Javascript Task Runners
Get Gulping with Javascript Task RunnersGet Gulping with Javascript Task Runners
Get Gulping with Javascript Task Runners
ColdFusionConference
 
Get Grulping with Javascript task runners
Get Grulping with Javascript task runnersGet Grulping with Javascript task runners
Get Grulping with Javascript task runners
devObjective
 
Full Stack Unit Testing
Full Stack Unit TestingFull Stack Unit Testing
Full Stack Unit Testing
GlobalLogic Ukraine
 
How to write Testable Javascript
How to write Testable JavascriptHow to write Testable Javascript
How to write Testable Javascript
ColdFusionConference
 
How do I write Testable Javascript - Presented at dev.Objective() June 16, 2016
How do I write Testable Javascript - Presented at dev.Objective() June 16, 2016How do I write Testable Javascript - Presented at dev.Objective() June 16, 2016
How do I write Testable Javascript - Presented at dev.Objective() June 16, 2016
Gavin Pickin
 
How do I Write Testable Javascript so I can Test my CF API on Server and Client
How do I Write Testable Javascript so I can Test my CF API on Server and ClientHow do I Write Testable Javascript so I can Test my CF API on Server and Client
How do I Write Testable Javascript so I can Test my CF API on Server and Client
ColdFusionConference
 
Grunt to automate JS build
Grunt to automate JS buildGrunt to automate JS build
Grunt to automate JS build
Tejaswita Takawale
 
AngularJS Unit Test
AngularJS Unit TestAngularJS Unit Test
AngularJS Unit Test
Chiew Carol
 
Grunt
GruntGrunt
Grunt
Andrés Callejas González
 
Let Grunt do the work, focus on the fun!
Let Grunt do the work, focus on the fun!Let Grunt do the work, focus on the fun!
Let Grunt do the work, focus on the fun!
Dirk Ginader
 
Grunt.js and Yeoman, Continous Integration
Grunt.js and Yeoman, Continous IntegrationGrunt.js and Yeoman, Continous Integration
Grunt.js and Yeoman, Continous Integration
David Amend
 
Javascript is your (Auto)mate
Javascript is your (Auto)mateJavascript is your (Auto)mate
Javascript is your (Auto)mate
Codemotion
 
Ustream vs Legacy, It's never too late to start your fight! #Jsist 2014
Ustream vs Legacy, It's never too late to start your fight! #Jsist 2014Ustream vs Legacy, It's never too late to start your fight! #Jsist 2014
Ustream vs Legacy, It's never too late to start your fight! #Jsist 2014
Máté Nádasdi
 
Grunt Continuous Development of the Front End Tier
Grunt Continuous Development of the Front End TierGrunt Continuous Development of the Front End Tier
Grunt Continuous Development of the Front End Tier
Erick Brito
 
Let Grunt do the work, focus on the fun! [Open Web Camp 2013]
Let Grunt do the work, focus on the fun! [Open Web Camp 2013]Let Grunt do the work, focus on the fun! [Open Web Camp 2013]
Let Grunt do the work, focus on the fun! [Open Web Camp 2013]
Dirk Ginader
 
How do I write Testable Javascript so I can Test my CF API on Server and Client
How do I write Testable Javascript so I can Test my CF API on Server and ClientHow do I write Testable Javascript so I can Test my CF API on Server and Client
How do I write Testable Javascript so I can Test my CF API on Server and Client
Gavin Pickin
 
Zero-config JavaScript apps with RaveJS -- SVCC fall 2014
Zero-config JavaScript apps with RaveJS -- SVCC fall 2014Zero-config JavaScript apps with RaveJS -- SVCC fall 2014
Zero-config JavaScript apps with RaveJS -- SVCC fall 2014
John Hann
 
An Introduction to the World of Testing for Front-End Developers
An Introduction to the World of Testing for Front-End DevelopersAn Introduction to the World of Testing for Front-End Developers
An Introduction to the World of Testing for Front-End Developers
FITC
 
FITC Web Unleashed 2017 - Introduction to the World of Testing for Front-End ...
FITC Web Unleashed 2017 - Introduction to the World of Testing for Front-End ...FITC Web Unleashed 2017 - Introduction to the World of Testing for Front-End ...
FITC Web Unleashed 2017 - Introduction to the World of Testing for Front-End ...
Haris Mahmood
 
Get Gulping with Javascript Task Runners
Get Gulping with Javascript Task RunnersGet Gulping with Javascript Task Runners
Get Gulping with Javascript Task Runners
ColdFusionConference
 
Get Grulping with Javascript task runners
Get Grulping with Javascript task runnersGet Grulping with Javascript task runners
Get Grulping with Javascript task runners
devObjective
 
How do I write Testable Javascript - Presented at dev.Objective() June 16, 2016
How do I write Testable Javascript - Presented at dev.Objective() June 16, 2016How do I write Testable Javascript - Presented at dev.Objective() June 16, 2016
How do I write Testable Javascript - Presented at dev.Objective() June 16, 2016
Gavin Pickin
 
How do I Write Testable Javascript so I can Test my CF API on Server and Client
How do I Write Testable Javascript so I can Test my CF API on Server and ClientHow do I Write Testable Javascript so I can Test my CF API on Server and Client
How do I Write Testable Javascript so I can Test my CF API on Server and Client
ColdFusionConference
 
AngularJS Unit Test
AngularJS Unit TestAngularJS Unit Test
AngularJS Unit Test
Chiew Carol
 
Ad

More from Lars Thorup (19)

100 tests per second - 40 releases per week
100 tests per second - 40 releases per week100 tests per second - 40 releases per week
100 tests per second - 40 releases per week
Lars Thorup
 
SQL or NoSQL - how to choose
SQL or NoSQL - how to chooseSQL or NoSQL - how to choose
SQL or NoSQL - how to choose
Lars Thorup
 
Super fast end-to-end-tests
Super fast end-to-end-testsSuper fast end-to-end-tests
Super fast end-to-end-tests
Lars Thorup
 
Extreme Programming - to the next-level
Extreme Programming - to the next-levelExtreme Programming - to the next-level
Extreme Programming - to the next-level
Lars Thorup
 
Advanced Javascript Unit Testing
Advanced Javascript Unit TestingAdvanced Javascript Unit Testing
Advanced Javascript Unit Testing
Lars Thorup
 
Unit testing legacy code
Unit testing legacy codeUnit testing legacy code
Unit testing legacy code
Lars Thorup
 
Advanced QUnit - Front-End JavaScript Unit Testing
Advanced QUnit - Front-End JavaScript Unit TestingAdvanced QUnit - Front-End JavaScript Unit Testing
Advanced QUnit - Front-End JavaScript Unit Testing
Lars Thorup
 
Put "fast" back in "fast feedback"
Put "fast" back in "fast feedback"Put "fast" back in "fast feedback"
Put "fast" back in "fast feedback"
Lars Thorup
 
Database Schema Evolution
Database Schema EvolutionDatabase Schema Evolution
Database Schema Evolution
Lars Thorup
 
Advanced Jasmine - Front-End JavaScript Unit Testing
Advanced Jasmine - Front-End JavaScript Unit TestingAdvanced Jasmine - Front-End JavaScript Unit Testing
Advanced Jasmine - Front-End JavaScript Unit Testing
Lars Thorup
 
Javascript unit testing with QUnit and Sinon
Javascript unit testing with QUnit and SinonJavascript unit testing with QUnit and Sinon
Javascript unit testing with QUnit and Sinon
Lars Thorup
 
Automated Performance Testing
Automated Performance TestingAutomated Performance Testing
Automated Performance Testing
Lars Thorup
 
Test and Behaviour Driven Development (TDD/BDD)
Test and Behaviour Driven Development (TDD/BDD)Test and Behaviour Driven Development (TDD/BDD)
Test and Behaviour Driven Development (TDD/BDD)
Lars Thorup
 
Agile Contracts
Agile ContractsAgile Contracts
Agile Contracts
Lars Thorup
 
High Performance Software Engineering Teams
High Performance Software Engineering TeamsHigh Performance Software Engineering Teams
High Performance Software Engineering Teams
Lars Thorup
 
Elephant Carpaccio
Elephant CarpaccioElephant Carpaccio
Elephant Carpaccio
Lars Thorup
 
Automated Testing for Embedded Software in C or C++
Automated Testing for Embedded Software in C or C++Automated Testing for Embedded Software in C or C++
Automated Testing for Embedded Software in C or C++
Lars Thorup
 
Unit Testing in JavaScript with MVC and QUnit
Unit Testing in JavaScript with MVC and QUnitUnit Testing in JavaScript with MVC and QUnit
Unit Testing in JavaScript with MVC and QUnit
Lars Thorup
 
Introduction to Automated Testing
Introduction to Automated TestingIntroduction to Automated Testing
Introduction to Automated Testing
Lars Thorup
 
100 tests per second - 40 releases per week
100 tests per second - 40 releases per week100 tests per second - 40 releases per week
100 tests per second - 40 releases per week
Lars Thorup
 
SQL or NoSQL - how to choose
SQL or NoSQL - how to chooseSQL or NoSQL - how to choose
SQL or NoSQL - how to choose
Lars Thorup
 
Super fast end-to-end-tests
Super fast end-to-end-testsSuper fast end-to-end-tests
Super fast end-to-end-tests
Lars Thorup
 
Extreme Programming - to the next-level
Extreme Programming - to the next-levelExtreme Programming - to the next-level
Extreme Programming - to the next-level
Lars Thorup
 
Advanced Javascript Unit Testing
Advanced Javascript Unit TestingAdvanced Javascript Unit Testing
Advanced Javascript Unit Testing
Lars Thorup
 
Unit testing legacy code
Unit testing legacy codeUnit testing legacy code
Unit testing legacy code
Lars Thorup
 
Advanced QUnit - Front-End JavaScript Unit Testing
Advanced QUnit - Front-End JavaScript Unit TestingAdvanced QUnit - Front-End JavaScript Unit Testing
Advanced QUnit - Front-End JavaScript Unit Testing
Lars Thorup
 
Put "fast" back in "fast feedback"
Put "fast" back in "fast feedback"Put "fast" back in "fast feedback"
Put "fast" back in "fast feedback"
Lars Thorup
 
Database Schema Evolution
Database Schema EvolutionDatabase Schema Evolution
Database Schema Evolution
Lars Thorup
 
Advanced Jasmine - Front-End JavaScript Unit Testing
Advanced Jasmine - Front-End JavaScript Unit TestingAdvanced Jasmine - Front-End JavaScript Unit Testing
Advanced Jasmine - Front-End JavaScript Unit Testing
Lars Thorup
 
Javascript unit testing with QUnit and Sinon
Javascript unit testing with QUnit and SinonJavascript unit testing with QUnit and Sinon
Javascript unit testing with QUnit and Sinon
Lars Thorup
 
Automated Performance Testing
Automated Performance TestingAutomated Performance Testing
Automated Performance Testing
Lars Thorup
 
Test and Behaviour Driven Development (TDD/BDD)
Test and Behaviour Driven Development (TDD/BDD)Test and Behaviour Driven Development (TDD/BDD)
Test and Behaviour Driven Development (TDD/BDD)
Lars Thorup
 
High Performance Software Engineering Teams
High Performance Software Engineering TeamsHigh Performance Software Engineering Teams
High Performance Software Engineering Teams
Lars Thorup
 
Elephant Carpaccio
Elephant CarpaccioElephant Carpaccio
Elephant Carpaccio
Lars Thorup
 
Automated Testing for Embedded Software in C or C++
Automated Testing for Embedded Software in C or C++Automated Testing for Embedded Software in C or C++
Automated Testing for Embedded Software in C or C++
Lars Thorup
 
Unit Testing in JavaScript with MVC and QUnit
Unit Testing in JavaScript with MVC and QUnitUnit Testing in JavaScript with MVC and QUnit
Unit Testing in JavaScript with MVC and QUnit
Lars Thorup
 
Introduction to Automated Testing
Introduction to Automated TestingIntroduction to Automated Testing
Introduction to Automated Testing
Lars Thorup
 
Ad

Recently uploaded (12)

Camil Institutional Presentation_mai25_vFR.pdf
Camil Institutional Presentation_mai25_vFR.pdfCamil Institutional Presentation_mai25_vFR.pdf
Camil Institutional Presentation_mai25_vFR.pdf
CAMILRI
 
Pieter Stalenhoef_ Proven Investment Professional with Expertise in Fund Mana...
Pieter Stalenhoef_ Proven Investment Professional with Expertise in Fund Mana...Pieter Stalenhoef_ Proven Investment Professional with Expertise in Fund Mana...
Pieter Stalenhoef_ Proven Investment Professional with Expertise in Fund Mana...
WilliamClack2
 
Tax-Deferred Growth & Indexed Annuities_ Secure Your Financial Future.pptx
Tax-Deferred Growth & Indexed Annuities_ Secure Your Financial Future.pptxTax-Deferred Growth & Indexed Annuities_ Secure Your Financial Future.pptx
Tax-Deferred Growth & Indexed Annuities_ Secure Your Financial Future.pptx
iulfinancial6
 
Best Practices for NFT Investing and Security.docx
Best Practices for NFT Investing and Security.docxBest Practices for NFT Investing and Security.docx
Best Practices for NFT Investing and Security.docx
taymormohse7
 
最新版西班牙塞维利亚大学毕业证(US毕业证书)原版定制
最新版西班牙塞维利亚大学毕业证(US毕业证书)原版定制最新版西班牙塞维利亚大学毕业证(US毕业证书)原版定制
最新版西班牙塞维利亚大学毕业证(US毕业证书)原版定制
Taqyea
 
最新版美国杜肯大学毕业证(DU毕业证书)原版定制
最新版美国杜肯大学毕业证(DU毕业证书)原版定制最新版美国杜肯大学毕业证(DU毕业证书)原版定制
最新版美国杜肯大学毕业证(DU毕业证书)原版定制
Taqyea
 
2025-06-11 North Arrow Update [NT Update]_WEBSITE.pdf
2025-06-11 North Arrow Update [NT Update]_WEBSITE.pdf2025-06-11 North Arrow Update [NT Update]_WEBSITE.pdf
2025-06-11 North Arrow Update [NT Update]_WEBSITE.pdf
narminerals
 
Equinox Gold Calibre Mining Corporate Presentation
Equinox Gold Calibre Mining Corporate PresentationEquinox Gold Calibre Mining Corporate Presentation
Equinox Gold Calibre Mining Corporate Presentation
Equinox Gold Corp.
 
最新版德国汉堡造型艺术学院毕业证(HFBK毕业证书)原版定制
最新版德国汉堡造型艺术学院毕业证(HFBK毕业证书)原版定制最新版德国汉堡造型艺术学院毕业证(HFBK毕业证书)原版定制
最新版德国汉堡造型艺术学院毕业证(HFBK毕业证书)原版定制
Taqyea
 
Camil Institutional Presentation_mai25_vFR.pdf
Camil Institutional Presentation_mai25_vFR.pdfCamil Institutional Presentation_mai25_vFR.pdf
Camil Institutional Presentation_mai25_vFR.pdf
CAMILRI
 
Camil Institutional Presentation_May2025
Camil Institutional Presentation_May2025Camil Institutional Presentation_May2025
Camil Institutional Presentation_May2025
CAMILRI
 
最新版西班牙加那利群岛拉斯帕尔马斯大学毕业证(ULPGC毕业证书)原版定制
最新版西班牙加那利群岛拉斯帕尔马斯大学毕业证(ULPGC毕业证书)原版定制最新版西班牙加那利群岛拉斯帕尔马斯大学毕业证(ULPGC毕业证书)原版定制
最新版西班牙加那利群岛拉斯帕尔马斯大学毕业证(ULPGC毕业证书)原版定制
Taqyea
 
Camil Institutional Presentation_mai25_vFR.pdf
Camil Institutional Presentation_mai25_vFR.pdfCamil Institutional Presentation_mai25_vFR.pdf
Camil Institutional Presentation_mai25_vFR.pdf
CAMILRI
 
Pieter Stalenhoef_ Proven Investment Professional with Expertise in Fund Mana...
Pieter Stalenhoef_ Proven Investment Professional with Expertise in Fund Mana...Pieter Stalenhoef_ Proven Investment Professional with Expertise in Fund Mana...
Pieter Stalenhoef_ Proven Investment Professional with Expertise in Fund Mana...
WilliamClack2
 
Tax-Deferred Growth & Indexed Annuities_ Secure Your Financial Future.pptx
Tax-Deferred Growth & Indexed Annuities_ Secure Your Financial Future.pptxTax-Deferred Growth & Indexed Annuities_ Secure Your Financial Future.pptx
Tax-Deferred Growth & Indexed Annuities_ Secure Your Financial Future.pptx
iulfinancial6
 
Best Practices for NFT Investing and Security.docx
Best Practices for NFT Investing and Security.docxBest Practices for NFT Investing and Security.docx
Best Practices for NFT Investing and Security.docx
taymormohse7
 
最新版西班牙塞维利亚大学毕业证(US毕业证书)原版定制
最新版西班牙塞维利亚大学毕业证(US毕业证书)原版定制最新版西班牙塞维利亚大学毕业证(US毕业证书)原版定制
最新版西班牙塞维利亚大学毕业证(US毕业证书)原版定制
Taqyea
 
最新版美国杜肯大学毕业证(DU毕业证书)原版定制
最新版美国杜肯大学毕业证(DU毕业证书)原版定制最新版美国杜肯大学毕业证(DU毕业证书)原版定制
最新版美国杜肯大学毕业证(DU毕业证书)原版定制
Taqyea
 
2025-06-11 North Arrow Update [NT Update]_WEBSITE.pdf
2025-06-11 North Arrow Update [NT Update]_WEBSITE.pdf2025-06-11 North Arrow Update [NT Update]_WEBSITE.pdf
2025-06-11 North Arrow Update [NT Update]_WEBSITE.pdf
narminerals
 
Equinox Gold Calibre Mining Corporate Presentation
Equinox Gold Calibre Mining Corporate PresentationEquinox Gold Calibre Mining Corporate Presentation
Equinox Gold Calibre Mining Corporate Presentation
Equinox Gold Corp.
 
最新版德国汉堡造型艺术学院毕业证(HFBK毕业证书)原版定制
最新版德国汉堡造型艺术学院毕业证(HFBK毕业证书)原版定制最新版德国汉堡造型艺术学院毕业证(HFBK毕业证书)原版定制
最新版德国汉堡造型艺术学院毕业证(HFBK毕业证书)原版定制
Taqyea
 
Camil Institutional Presentation_mai25_vFR.pdf
Camil Institutional Presentation_mai25_vFR.pdfCamil Institutional Presentation_mai25_vFR.pdf
Camil Institutional Presentation_mai25_vFR.pdf
CAMILRI
 
Camil Institutional Presentation_May2025
Camil Institutional Presentation_May2025Camil Institutional Presentation_May2025
Camil Institutional Presentation_May2025
CAMILRI
 
最新版西班牙加那利群岛拉斯帕尔马斯大学毕业证(ULPGC毕业证书)原版定制
最新版西班牙加那利群岛拉斯帕尔马斯大学毕业证(ULPGC毕业证书)原版定制最新版西班牙加那利群岛拉斯帕尔马斯大学毕业证(ULPGC毕业证书)原版定制
最新版西班牙加那利群岛拉斯帕尔马斯大学毕业证(ULPGC毕业证书)原版定制
Taqyea
 

Continuous Integration for front-end JavaScript

  • 1. Continuous Integration for front-end JavaScript Lars Thorup ZeaLake Software Consulting April, 2013
  • 2. Who is Lars Thorup? ● Software developer/architect ● JavaScript, C# ● Test Driven Development ● Continuous Integration ● Coach: Teaching agile and automated testing ● Advisor: Assesses software projects and companies ● Founder of ZeaLake
  • 3. Continuous Integration Code CI-server Results function createBoard() { ... } static analysis errors test runner Tests test('createBoard', { ... coverage coverage analysis }); minification distributables
  • 4. GruntJS ● Command line ● Good support for ● NodeJS ● RequireJS ● CoffeeScript ● Static analysis ● JSHint ● Lots of other plugins ● Run tests in PhantomJS ● Popular and actively ● QUnit developed ● Jasmine ● and others ● Code Coverage ● Istanbul ● Blanket
  • 5. src/test/code.test.js describe('durationInEnglish', function () { it('should return "now" when duration is 0', function () { expect(durationInEnglish(0)).toBe('now'); }); it('should return "x seconds ago" when ...', function () { var now = new Date(2013, 04, 19, 11, 00, 17); var then = new Date(2013, 04, 19, 11, 00, 00); expect(durationInEnglish(now - then)).toBe('17 seconds ago'); }) });
  • 6. src/js/code.js function durationInEnglish(milliseconds) { var seconds = milliseconds / 1000; if(seconds === 0) { return 'now'; } else if(seconds < 60) { return seconds + ' seconds ago'; } else { return 'whenever'; } }
  • 7. package.json { "name": "gruntdemo", "version": "0.1.1-1", "devDependencies": { "grunt-cli": "0.1.6", "grunt": "0.4.1", "grunt-contrib-jshint": "~0.1.1", "grunt-contrib-jasmine": "0.4.1", "grunt-template-jasmine-istanbul": "0.2.0" } } >npm install
  • 8. Gruntfile.js module.exports = function (grunt) { var gruntConfig = {}; // task definitions ... // grunt grunt.initConfig(gruntConfig); };
  • 9. Gruntfile.js - jshint grunt.loadNpmTasks('grunt-contrib-jshint'); gruntConfig.jshint = { all: [ '*.js', 'src/**/*.js' ] }; >grunt jshint Running "jshint:all" (jshint) task >> 3 files lint free.
  • 10. Gruntfile.js - jasmine grunt.loadNpmTasks('grunt-contrib-jasmine'); gruntConfig.jasmine = { src: { src: [ 'src/js/**/*.js' ], options: { specs: 'src/test/**/*.test.js', junit: { path: 'output/testresults' } } } >grunt jasmine:src }; Running "jasmine:src" (jasmine) task Testing jasmine specs via phantom .. 2 specs in 0.109s. >> 0 failures
  • 11. Gruntfile.js - istanbul gruntConfig.jasmine.istanbul = { src: gruntConfig.jasmine.src.src, options: { specs: gruntConfig.jasmine.src.options.specs, template: require('grunt-template-jasmine-istanbul'), templateOptions: { coverage: 'output/coverage/coverage.json', report: [ {type: 'html', options: {dir: 'output/coverage'}}, {type: 'text-summary'} ] } >grunt jasmine:istanbul Running "jasmine:istanbul" (jasmine) task } Testing jasmine specs via phantom }; .. ========== Coverage summary =========== Statements : 85.71% ( 6/7 ) Branches : 75% ( 3/4 ) Functions : 100% ( 1/1 ) Lines : 85.71% ( 6/7 ) =======================================