- install nodejs and npm
- clone repository
- run
npm install
To make sure everything works correctly, run npm test
.
If you have some time (15-20 min) you can run npm run test:e2e
to perform integration tests.
throwing an exception
throw new Error()
rejecting a Promise
reject(new Error())
or returning an error value
return new Error()
catch(ex){
if(ex instanceof MyCustomError){
// do smth.
}
}
Create custom errors only when you need to handle this error type specifically.
Otherwise just use new Error('message')
function CustomError(message, nestedError, otherData) {
var error = Error.call(this, message);
this.name = 'CustomError';
this.message = error.message;
this.stack = error.stack;
this.nestedError = nestedError;
this.otherData = otherData;
}
CustomError.prototype = Object.create(Error.prototype);
CustomError.prototype.constructor = CustomError;
- If it makes sense in the global application flow - make api call retry/repeat itself in case of failure.
For this purpose use
helpers/retry.js
. - Some of api calls are expected to return promise rejection or falsy return value in case of failure so that user may decide if they want to repeat an action.
Simple and well decoupled code is covered with unit tests, you can find them in /test/unit
folder, and run with npm run test:unit
Peerio Icebear mainly relies on integration (e2e) tests written using cucumber.
To run all e2e tests execute npm run test:e2e
.
When you are working on some prticular test scenarios or features, you can mark them with @wip
tag, which will make 2 things happen.
- These features/scenarios will not run on CI
- Locally you can run
npm run test:e2e:wip
to only run tagged scenarios.
Don't forget to remove the @wip tag when the work is done!
There's another tag helping to debug scenarios in chrome dev tools - @debug
.
Just mark your scenarios with the tag and run npm run test:e2e:debug
.
Then go to chrome://inspect
in Chrome browser to open the devtools for your test scenarios.