Difference between revisions of "TDD"

From Wiki2
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
==front-end testing karma==
==front-end testing karma==
Now working out of c://wamp/www where all the packages get installed. To run testing you need to access the karma and its submodules there but you then use the local conf file
Now working out of c://wamp/www where all the packages get installed. To run testing you need to access the karma and its submodules there but you then use the local conf file. (npm scripts do not work)


c://wamp/www/node_modules/karma/bin/karma start karmocha.conf.js  
c://wamp/www/node_modules/karma/bin/karma start karmocha.conf.js
 
*http://attackofzach.com/setting-up-a-project-using-karma-with-mocha-and-chai/
*http://www.bradoncode.com/blog/2015/05/19/karma-angularjs-testing/
*https://docs.angularjs.org/api/ngMock/service/$httpBackend
*[https://gist.github.com/blesh/8846528 basics on unit testing controller]
*http://stackoverflow.com/questions/15048132/angularjs-promise-not-being-resolved-in-unit-test
==testing==
==testing==
====regression testing====
====regression testing====

Latest revision as of 14:29, 17 April 2016

front-end testing karma

Now working out of c://wamp/www where all the packages get installed. To run testing you need to access the karma and its submodules there but you then use the local conf file. (npm scripts do not work)

c://wamp/www/node_modules/karma/bin/karma start karmocha.conf.js  

testing

regression testing

Regression testing is a type of software testing that seeks to uncover new software bugs, or regressions, in existing functional and non-functional areas of a system after changes such as enhancements, patches or configuration changes, have been made to them. The purpose of regression testing is to ensure that changes such as those mentioned above have not introduced new faults. One of the main reasons for regression testing is to determine whether a change in one part of the software affects other parts of the software. Regression tests can be broadly categorized as functional tests or unit tests. Functional tests exercise the complete program with various inputs. Unit tests exercise individual functions, subroutines, or object methods

Contrast with non-regression testing (usually validation-test for a new issue), which aims to verify whether, after introducing or updating a given software application, the change has had the intended effect.

http://jsfiddle.net/fdietz/2Ny8x/

npm install mocha chai --save-dev

  same as
npm i -D mocha chai

create a test file src/index.test.js

 var expect = require('chai').expect;
 var starWars = require('./index');
 describe('starwars-names', function() {
   describe('all', function() {
     it('should be an array of strings', function() {
       expect(starWars.all).to.satisfy(isArrayOfStrings);
       function isArrayOfStrings(array) {
         return array.every(function(item) {
           return typeof item === 'string';
         });
       }
     });
     it('should contain `Luke Skywalker`', function() {
       expect(starWars.all).to.include('Luke Skywalker');
     });
   });
   describe('random', function() {
     it('should return a random item from the starWars.all', function() {
       var randomItem = starWars.random();
       expect(starWars.all).to.include(randomItem);
     });
   });
 });

change package.json to run tests (automatically on update -w)

 "scripts": {
   "test": "mocha src/index.test.js -w"
 },
 npm test


expect.js syntax

http://thewayofcode.wordpress.com/2013/04/21/how-to-build-and-test-rest-api-with-nodejs-express-mocha/

http://stackoverflow.com/questions/9517880/how-does-one-unit-test-routes-with-express

http://webapplog.com/tutorial-node-js-and-mongodb-json-rest-api-server-with-mongoskin-and-express-js/

https://github.com/azat-co/rest-api-express/blob/master/express.test.js

http://stackoverflow.com/questions/14665115/writing-tests-for-rest-api-nodejs-mongodb

http://visionmedia.github.io/mocha/

http://taylor.fausak.me/2013/02/17/testing-a-node-js-http-server-with-mocha/

http://www.wekeroad.com/2012/02/25/testing-your-model-with-mocha-mongo-and-nodejs/

https://github.com/visionmedia/supertest/blob/master/test/supertest.js

http://visionmedia.github.io/superagent/

http://jsbin.com/wodonuce/1/edit