Javascript assignments, tasks and katas
Yet another javascript assignments. There are a lot of interactive javascript resources for beginners, but most of them are online and do not cover the modern programming workflow. There are some excellent training resources on github (https://github.com/rmurphey/js-assessment, https://github.com/mrdavidlaing/javascript-koans, https://github.com/vasanthk/js-bits etc) but they are not exactly simulate the everyday programming process. So the motivation of this project is to show TDD process in the wild to the beginners. Assingment tests are implemented in various ways to feel a difference and gain the experience what manner is good, what is bad and what is ugly.
Another idea is to prepare assignment to cover all standard javascript functions, to drilling and mastering skills. Some tasks are practical, but some tasks are rather synthetic.
And the last idea is to inure trainees to work using unit test and feel uncomfortable when programming without tests.
To start javascript assignments please follow the next steps:
git clone https://github.com/<your-account>/js-assignments.git
from command line to download the repo.'rolling-scopes-school'
with your account name). git add README.md
git commit -m "Update the links"
git push origin master
npm install
from you repository folder to download the required modules. All dependent modules will be located in the node_modules folder.npm test
command to run all tests. You can run single file by passing it as argument npm test ./test/01-strings-tests.js
.
node_modules - app dependences restored by npm install
command, you can delete this folder and restore later again.
task - folder with tasks modules, it's your main folder.
test - folder with tests modules to verify the tasks completion.
Now you are ready to implement assignments. Tasks modules are located in the task folder. Each module consists of several tasks for specified topic. Each task is usually a regular function:
/**
* Returns the result of concatenation of two strings.
*
* @param {string} value1
* @param {string} value2
* @return {string}
*
* @example
* 'aa', 'bb' => 'aabb'
* 'aa','' => 'aa'
* '', 'bb' => 'bb'
*/
function concatenateStrings(value1, value2) {
throw new Error('Not implemented');
}
Resolve this task using the following TDD steps:
throw new Error('Not implemented');
and run the unit tests again. Find one test failed (red). Now it's time to fix it!
To debug tests you can use Node inspector. To install it just run npm install -g node-inspector
in your terminal. Then follow next steps:
debugger;
to the first line of your task.npm run test-debug ./test/01-strings-tests.js
.node-inspector
and copy link from the output.debugger;
from your task.There is an easier way to debug for beginners with free Visual Studio Code:
launch.json
launch.json
in the IDE, set the properties "program" and "args" (empty "args" value run all tests, to run particular test specify this test file in "args"):{
"version": "0.2.0",
"configurations": [
{
...
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
...
"args": ["./test/01-strings-tests.js"],
...
},
...
]
}
F5
to run debug.launch.json
is stored in the .vscode
project folder.##Contribution Feel free to contribute into this project. New tasks and katas are welcome.