Difference between revisions of "Npm"

From Wiki2
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
==Node package manager==
==Node package manager==
===updating gulp gyp jsdom===
So a quick solution for all node-gyp issues around some of the packages in which is thrown, is to update all those packages with:
$ npm install -g npm-check-updates
$ npm-check-updates -u
$ npm install
from egghead series https://egghead.io/series/how-to-write-an-open-source-javascript-library  https://github.com/kentcdodds/starwars-names.git
===versioning===
===versioning===


Line 20: Line 27:
  git push --tags
  git push --tags
  npm publish --tag beta
  npm publish --tag beta
{{:testing}}

Latest revision as of 15:08, 25 April 2016

Node package manager

updating gulp gyp jsdom

So a quick solution for all node-gyp issues around some of the packages in which is thrown, is to update all those packages with:

$ npm install -g npm-check-updates
$ npm-check-updates -u
$ npm install

from egghead series https://egghead.io/series/how-to-write-an-open-source-javascript-library https://github.com/kentcdodds/starwars-names.git

versioning

1.0.0 is typical with the major release number getting changed any time the api changes. Adding features would change the second digit and bug fixes would change the last digit.

process

modify package.json to new version, say 1.1.0
git add . -A
git commit -m 'about new version'
git push
git tag 1.1.0
git push --tags
npm publish

beta process

from current version, say 1.3.0 to add a beta feature bump the version to 1.4.0-beta.0

modify package.json to new version, say 1.4.0-beta.0
git add . -A
git commit -m 'about new beta version'
git push
git tag 1.4.0-beta.0
git push --tags
npm publish --tag beta

testing

mocha

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