用BASIC原则编写干净的JavaScript测试

Hold your BASIC shield armor while The JavaScript test bastards are coming

在JavaScript测试的混蛋们来的时候,保持你的BASIC盾牌装甲。

Language review: Jonathan Atia

语言评论。乔纳森-阿蒂亚

✨ Visit my workshop — Nodeconf is the biggest European Node.js conference (October 18th-19th) .?‍? I’ll hold this year a five hours comprehensive workshop about— “Node.js testing — beyond the basics”, visit here for more details

✨ 参观我的研讨会 - Nodeconf是欧洲最大的Node.js会议(10月18日至19日)。??今年我将举办一个5小时的综合研讨会,内容是--"Node.js测试--超越基础知识",访问这里了解更多细节

Why do many teams abandon testing

为什么许多团队放弃测试

Production code, the main code where the features live, might not be perfect. That’s a risk or a debt that teams manage in multiple ways. For testing code, the risk is much more dramatic — It can be abandoned altogether. Vanish, gone, not doing anything anymore. Hundreds of coding hours, meetings, and sweat can just get lost.

生产代码,即功能所在的主要代码,可能并不完美。这是一种风险或债务,团队可以通过多种方式管理。对于测试代码,风险要大得多--它可能被完全抛弃。消失了,不见了,不再有任何作用。数以百计的编码时间、会议和汗水可能就这样丢失了。

Have you encountered this? Here is a tyical story. 7 pm, late, it’s cold and dark outside. Sarah is a relatively new team member, and she is trying to deploy. All seems excellent except few tests, written by someone else, are failing. Sarah opens the tests file to look through those tests, her eyes can’t believe what they see — each test constitutes 50 lines of code (with Prettier it became 100 loc) including loops, if/else, callbacks. That’s annoying because she thought the challenging part was behind her — Coding the features. Wait, now she also notices that the test is calling other external classes that inherit from more classes and share state with other tests. It’s hard to follow the code traces, her eyes blink tiredly, 8 pm already, Sarah is angry and hungry, did I mention it’s raining outside?. Unlike the tests, the new code seems to work fine — Yes she also tested with Postman and her Browser. Desperately she makes a call to use the magic spell that makes all sorrows end. She adds one little and a sweet word — test.skip. All tests pass now. She deplo...

开通本站会员,查看完整译文。

首页 - Wiki
Copyright © 2011-2024 iteam. Current version is 2.137.3. UTC+08:00, 2024-11-27 01:47
浙ICP备14020137号-1 $访客地图$