rogerxu / rogerxu.github.io

Roger Xu's Blog
3 stars 2 forks source link

JavaScript Test Frameworks #36

Open rogerxu opened 8 years ago

rogerxu commented 8 years ago

An Overview of JavaScript Testing in 2021 | by Vitali Zaidman | Welldone Software | Medium

State of JS 2020: Testing

rogerxu commented 8 years ago

What are the differences between mocha, chai, karma, jasmine, should.js, etc. testing frameworks? - Stack Overflow

scraggo/comparing-javascript-test-runners: Comparing AVA, Jest, Mocha, and mocha-parallel-tests testing frameworks (github.com)

rogerxu commented 8 years ago

Karma

javascript - Karma vs testing framework Jasmine, Mocha, QUnit - Stack Overflow

Karma is a browser test runner.

The idea is that browsers do not have natively a concept of loading tests files, running them, and reporting results. What karma does is (roughly) :

Looking at each part :

  1. Those files will be your actual js files ; you will tell karma how to load them. If you use requirejs, there is a karma plugin, and some config is needed.
  2. Those tests can be written in a variety of Javascript testing framework (Jasmine, QUnit, Mocha) ; this is JS code that is run in the browser.
  3. The custom web page will be a bit different for each testing framework ; this is why karma has plugins for different frameworks.
  4. Karma can launch the page in many browsers (FF, Chrome, or headless browsers like PhantomJs.)
  5. Reporting to karma is, again, framework-dependant, and dealt with karma plugins.

So to answer your questions :

rogerxu commented 8 years ago

Jasmine vs. Mocha

Jasmine vs. Mocha, Chai, and Sinon - The JS Guy - David Tang

Jasmine vs. Mocha | Marco Franssen

JavaScript Testing Framework Comparison: Jasmine vs Mocha | Codementor

rogerxu commented 7 years ago

Mocks/Stubs

Sinon.JS - Documentation

rogerxu commented 7 years ago

Code Coverage

isparta

douglasduteil/isparta: A code coverage tool for ES6 (babel/6to5)

yarn add --dev babel-cli
yarn add --dev isparta
babel-node ./node_modules/isparta/bin/isparta cover ./node_modules/mocha/bin/_mocha

package.json

{
  "scripts": {
    "coverage": "babel-node ./node_modules/isparta/bin/isparta cover ./node_modules/mocha/bin/_mocha"
  }
}
rogerxu commented 7 years ago

tape

substack/tape: tap-producing test harness for node and browsers

rogerxu commented 7 years ago

JavaScript Testing: Unit vs Functional vs Integration Tests — SitePoint

rogerxu commented 6 years ago

Testing Pyramid