The Big Epic Rewrite Issue
维护者通常 1 天内回复
@searls 已经在做这个了。
开始于 2017年6月17日。
评估
这个 Issue 还没有评估数据。
描述
Starting with the setup work in #255, I've been undergoing an in-place rewrite of testdouble.js that essentially dogfoods both the library & Discovery Testing by replacing the library bit-by-bit.
This has been incredibly challenging for a variety of reasons, among them: keeping oneself unanchored by existing implementation when trying to think of a better design, coming up with useful names for (relative to most JS libs) very meta concepts, and resisting the urge to fix problems and incongruities in the existing implementation as I go. If this rewrite also substantially changes the public-facing behavior of the library, it's going to be like tuning two knobs on a radio at once, making everything more difficult.
Therefore, this thread will maintain 3 to-do lists for tracking progress of the rewrite. First: the actual progress so far incorporating the new implmentation. Second: the future work to undertake to "fix" what I identify as broken with the library after we call the rewrite "done". Third: internal improvements that should be tracked and made as part of the rewrite.
Progress so far.
testdouble.js has a pretty straightforward public-API:
- test double creation
- td.function (alias td.func)
- td.object
- td.constructor
- td.replace
- CommonJS module replacement (Node.js only)
- named property replacement
- td.when for stubbing
- td.verify for verifying calls
- matchers for both stubbing and verifying
- the same built-in matchers we have today
- the same matcher-creator function we provide today
- the special matchers like
captorandcallbackwhich enable other behavior
- td.reset for resetting test double state and undoing dependency replacement
- td.explain for providing metadata about a fake thing
- td.config for global config options (log level, which promise constructor to use, etc)
- Internal bits
- A logging facility
- An in-memory store for calls (
CallLog) - An in-memory store for stubbings (
StubbingRegister)
*being labeled complete here does not mean they are wired up in the deployed library, yet. They'll sit in the repo as inert code until they can go end-to-end. For instance, td.func() can't be replaced until its calls go in the same call log that td.verify() is looking at, otherwise the library wouldn't work. It truly is a big epic rewrite as a result, since almost everything depends on everything else because of how stateful a library this is.
Room to improve
Here's what I've identified as things to improve while working through everything. Some of these feel urgent enough that I'll incorporate them into the current implementation to avoid rewriting a bad thing.
- Improve
td.explainto accept any fake object/function/constructor and give you a way to navigate to its parents and children if it was a property of a fake thing - Get consistent about finding all properties on a function or object to be cloned or faked, that means enumerable/non-enumerable, inherited/owned. Currently all 3 creation methods identify these differently #257
- When replacing a function, replace it as a "plain" function or a constructor function consistently. Currently some places get the "if a constructor replace it this way" treatment and some don't. Getting consistent about how all functions are replaced will eliminate a lot of branching
- Do "deep" cloning & property faking as opposed to single-layer, since we can no longer reasonably assert the opinion that "good" modules be one or two layers deep, thanks to ES modules having a necessary layer beyond CJS ones #262
- Support ES getters and setters (right now, we're punting on getters & setters entirely; they dramatically complicate how we identify and track "properties" on objects)
Internal improvements
There are some things that can be improved/refactored without affecting public-facing behavior. Tracking those here:
-
td.func- instead of having magical fake functions flying about, create an actual
Doublevalue that knows a lot of metadata about the concept of a double (like therealthing its masking) - tracking parent/child relationships, improve the
nameof each test double function to concatenate all the names of its parents sotd.explainand error messages make it clear which test double is which - today's
td.functiontakes a second__optionalNameargument due to a quirk in how node-module replacement was written. This can be fixed by making
- instead of having magical fake functions flying about, create an actual
-
td.replace- for some reason the name of test doubles on default-export ES modules is just
.defaultwhich means they all look the same. the name should include the module path + the export name
- for some reason the name of test doubles on default-export ES modules is just
- 主要语言
- JavaScript
- 星标
- 1.4k
- 派生
- 141
- 平均合并
- 2 小时 30 分钟
- 30 天内合并 PR
- 10
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
testdouble/testdouble.js 的其他 Issue
-
Feature request: `td.func().reset()` (reset spy/stub state)可能已有人在做 @MatrixNeoKozak 于 3 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 45/100
testdouble/testdouble.js#529 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 35/100
testdouble/testdouble.js#296 ·
维护者通常 1 天内回复
-
enhancement
难度 5/5 一周以上 新手友好度 25/100
testdouble/testdouble.js#281 · 5 条评论 · 2 个 reaction ·
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 25/100
testdouble/testdouble.js#276 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 35/100
testdouble/testdouble.js#275 · 3 条评论 ·
维护者通常 1 天内回复
查看 testdouble/testdouble.js 的全部 Issue
相似的 Issue
-
[Website] Catalog: unknown sort value and mixed-case technology in the URL break the filters可能已有人在做 @barbierajput378-pixel 今天认领。 未关闭area/website framework/jekyll help wanted language/css language/javascript language/markdown
难度 2/5 1-3 小时 新手友好度 80/100
meshery/meshery.io#3088 · 1 条评论 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 74/100
firecrawl/firecrawl-mcp-server#548 ·
维护者通常 1 天内回复
-
Area:WebGL p5.js 2.0+
难度 2/5 1-3 小时 新手友好度 78/100
processing/p5.js#9302 ·
维护者通常 3 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
documentation good first issue hacktoberfest
难度 2/5 1-3 小时 新手友好度 70/100
wassim-azi/agy-powerline#47 ·
维护者通常 1 天内回复