I'll be using macOS but most of these tools are available on linux Windows systems may require you use different tools that what I have
- Install
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.2/install.sh | bash
- Add to profile
This is added to whatever shell profile you are using. Usually
.bashrc
or.zshrc
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
- Reload profile should only have to load the one you edited
source ~/.zshrc
source ~/.bashrc
- Verify NVM is installed
nvm -v
Now that NVM is installed, this becomes really simple. Unless you need a specific version, you can install the Latest LongTermSupport
- Install
nvm install --lts
- Verify install
node -v
which node
which npm
- Initialize the folder
npm init -y
- Install mocha and should
npm install --save-dev mocha should
- Create the Test File
/* test/test.js */
var should = require("should");
describe("Array", function() {
describe("#indexOf()", function() {
it("should return -1 when the value is not present", function() {
[1, 2, 3].indexOf(5).should.equal(-1);
});
});
});