TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Show HN: Pythagora – auto generated integration tests for Node.js API servers

8 点作者 zvonimirs超过 2 年前
Hi HN,<p>I just released my first npm package so wanted to share it here.<p>Pythagora is a Node.js module that creates automated integration tests for MERN&#x2F;MEAN apps by recording server activity.<p>To integrate Pythagora, you need to paste one line of code to your repository and run the Pythagora capture CLI command. Then, just play around with your app and from all API requests and database queries Pythagora will generate integration tests.<p>When running tests, it doesn’t matter what database is your Node.js connected to or what is the state of that database. Actually, that database is never touched or used —&gt; instead, Pythagora creates a special, ephemeral `pythagoraDb` database, which it uses to restore the data before each test is executed, that was present at the time when the test was recorded. Because of this, tests can be run on any machine or environment.<p>Also, *if the request updates the database, after the API returns the response, Pythagora checks the database to see if it was updated correctly*.<p>Finally, Pythagora tracks (using istanbul&#x2F;nyc) lines of code that were triggered during tests, so you know how much of your code is covered.<p>Our goal is to help teams that don’t have time to properly manage their test suite to cover their entire codebase with as little as 1 hour of their time. We tested Pythagora on open source clones of apps like Reddit, IG, etc. and we were able to get to 50% of code coverage within 10 minutes and to 90% within 1 hour of playing around these apps.<p>Feel free to try out the Pythagora npm package - https:&#x2F;&#x2F;www.npmjs.com&#x2F;package&#x2F;pythagora<p>And the source code on Github - https:&#x2F;&#x2F;github.com&#x2F;Pythagora-io&#x2F;pythagora<p>We’re excited to hear what you think.<p>How do you write integration tests for an API server? Would you consider using Pythagora instead&#x2F;along with your system?<p>If not, we would love to hear what are your concerns and why this wouldn’t work for you?

1 comment

james-revisoai超过 2 年前
This is a brilliant idea. One of those &quot;why hasn&#x27;t that happened yet??&quot; ones.<p>Is there any way for me to obscure PII data easily? or anonymise any data recognised as file contents or base64? That&#x27;d help.<p>Have you considered hooking up alerts. For example to run `npx pythagora --script .&#x2F;path&#x2F;to&#x2F;your&#x2F;server.js --mode test` but with an option to pass a key&#x2F;function to send alerts(perhaps just picking up test fail and dealing with it in the CI is better though) if a test fails that previously passed (wherever that command is run, so in the CI or if manually ran).<p>We do use socket.io for a massive amount of our requests so I don&#x27;t think it&#x27;d cover that (happy if wrong?) but I will look into if we can add a pull request for socket.io support, if you are interested in that scope creep... As that would be very powerful.
评论 #34727128 未加载