js assignments
v1.1
另一個JavaScript分配。初學者有很多交互式JavaScript資源,但是其中大多數是在線的,並且不涵蓋現代的編程工作流程。 Github(https://github.com/rmurphey/js-assessment,https://github.com/mrdavidlaing/javascript-koans,https://github.com/vasanthk/js-bits et ynevermite nevermitignming contameming crompticemming crompticeming流程,都有一些出色的培訓資源。因此,該項目的動機是向初學者展示野外TDD過程。屁股測試以各種方式實施,以感受到差異,並獲得經驗的好處,什麼是壞事和醜陋。
另一個想法是準備任務,以涵蓋所有標準的JavaScript功能,以鑽探和掌握技能。有些任務是實用的,但是有些任務是合成的。
最後一個想法是要使用單位測試工作,並在沒有測試的情況下進行編程時會感到不舒服。
git clone https://github.com/<your-account>/js-assignments.git從命令行下載倉庫。'it-shark-pro'的出現)。 git add README.md
git commit -m " Update the links "
git push origin masternpm install以下載所需的模塊。所有因模塊將位於Node_modules文件夾中。npm test命令運行所有測試。您可以通過將單個文件作為參數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.現在,您準備實施作業。任務模塊位於任務文件夾中。每個模塊都由指定主題的幾個任務組成。每個任務通常都是常規功能:
/**
* 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' ) ;
}使用以下TDD步驟解決此任務:
throw new Error ( 'Not implemented' ) ;並再次運行單元測試。找到一個測試失敗(紅色)。現在該解決它了!
要調試測試,您可以使用節點檢查器。要安裝它,只需在您的終端中運行npm install -g node-inspector即可。然後執行下一步:
debugger;到您任務的第一行。npm run test-debug ./test/01-strings-tests.js運行測試文件。node-inspector中,並從輸出複制鏈接。debugger;從你的任務中。有一種更簡單的方法可以通過免費的Visual Studio代碼進行調試:
launch.json遵循指令。launch.json ,設置屬性“程序”和“ args”(空“ args”值運行所有測試,以在“ args”中運行特定的測試指定此測試文件): {
"version": "0.2.0",
"configurations": [
{
...
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
...
"args": ["./test/01-strings-tests.js"],
...
},
...
]
}
F5進行調試。launch.json存儲在.vscode項目文件夾中。 隨時為該項目做出貢獻。歡迎新任務和卡塔斯。
修復已執行的絨毛:
npm run lint -- --fix