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