A simple set-up to crack code challenges, executing in VS Code and testing with Jest as you go.
- Node.js
- npm / yarn
- Jest (testing)
- nodemon (watching for changes and executing JavaScript code in the console)
- Copy
example
folder and rename for your challenge - Modify
solution.test.js
according to your tests:
const tests = {
// Format:
// 'test name': [[arguments], expected result]
"adds 1 + 2 to equal 3": [[1, 2], 3],
"adds 1 + 5 to equal 6": [[1, 5], 6],
// if there's only one argument:
"some name": [1, 6],
// if an array is argumented:
"some name": [[[2, 3]], 6],
// add any number of tests
};
- Work in
solution.js
as usual - To execute your code on every save:
$ nodemon ./folder-name/solution.js
- To run tests:
$ yarn test ./folder-name
or with testing on every save
$ yarn test ./folder-name --watch