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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Polly.js – Record, replay, and stub HTTP interactions

471 点作者 zwentz将近 7 年前

25 条评论

stephen将近 7 年前
Looks well done (it uses unicode art, so it must be amazing) but I have a fundamental distrust&#x2F;dislike of record&#x2F;replay frameworks...just seems like you&#x27;re papering over an inherently bad testing approach.<p>E.g. sure, when replays work, they&#x27;re great, but:<p>a) you have to do a manual recording to create them the first time (which means manually setting up test data in production that is just-right for your test case)<p>b) you have to manually re-record when they fail (and again means you have manually go back and restore the test data in production that is just-right for your test case...and odds are you weren&#x27;t the one who originally recorded this test, so good luck guessing exactly what that was).<p>In both cases, you&#x27;ve accepted that you can&#x27;t easily setup specific, isolated test data in your upstream system, and are really just doing &quot;slightly faster manual testing&quot;.<p>So, IMO, you should focus on solving the core issue: the uncontrollable upstream system.<p>Or, if you can&#x27;t, decouple all of your automated tests from it fully, and just accept that cross-system tests against a datasource you can&#x27;t control is not a fun&#x2F;good way to write more than a handful of tests (e.g. ~5 smoke tests are fine, but ~100s of record&#x2F;replay tests for minute boundary cases sounds terrible).
评论 #17309259 未加载
评论 #17311095 未加载
评论 #17309257 未加载
评论 #17309870 未加载
评论 #17312332 未加载
评论 #17313002 未加载
评论 #17309184 未加载
burger_moon将近 7 年前
I would love to hear from people involved in projects like this, what kind of work&#x2F; how much, was done to get it ready for and approved to be open sourced by the company.<p>Especially at large corps like Netflix I&#x27;m sure there&#x27;s a lot of hoops to jump through.
评论 #17312472 未加载
评论 #17309160 未加载
评论 #17308610 未加载
jorisd将近 7 年前
This is very cool, solving some issues I no doubt many people have when writing tests against a (fast-)moving target. I&#x27;ll definitely give it a try in my next project.<p>I looked through the codebase, and noticed that this uses a custom data format to persist HTTP requests and responses in local storage. I&#x27;m not sure if it&#x27;s technically possible in all circumstances, but I think it might be valuable to have requests and responses be stored as HAR 1.2 [1] when possible, so that the trace can be used by other tools [2] to aid in debugging, verifying and analyzing behaviour as well as perhaps automated creation of load&#x2F;performance tests.<p>[1] - <a href="http:&#x2F;&#x2F;www.softwareishard.com&#x2F;blog&#x2F;har-12-spec&#x2F;" rel="nofollow">http:&#x2F;&#x2F;www.softwareishard.com&#x2F;blog&#x2F;har-12-spec&#x2F;</a><p>[2] - e.g. <a href="https:&#x2F;&#x2F;toolbox.googleapps.com&#x2F;apps&#x2F;har_analyzer&#x2F;" rel="nofollow">https:&#x2F;&#x2F;toolbox.googleapps.com&#x2F;apps&#x2F;har_analyzer&#x2F;</a>
nitinreddy88将近 7 年前
There is already famous Policy package for .NET with same name<p><a href="https:&#x2F;&#x2F;github.com&#x2F;App-vNext&#x2F;Polly" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;App-vNext&#x2F;Polly</a>
vaidik将近 7 年前
I used to use nock which would work very well in node environments. But this works in the browser as well. So I guess this can be fairly helpful while writing tests post development. If you are doing TDD, then recording&#x2F;replaying doesn&#x27;t fit anywhere in the development cycle.<p>I like the API of this library and the browser support that was missing in nock. So thanks Netflix! Although it would have been nice to see nock add this support. Which is what I wonder - why not just contribute to existing libraries.
评论 #17310407 未加载
yawz将近 7 年前
I love the name! &quot;Polly&quot; repeats everything... and wants biscuit every now and then :).
评论 #17308781 未加载
bicubic将近 7 年前
Related to that, is there anything that allows to completely save the state of a modern website with all of the fetch requests and websocket related stuff it fired off?<p>I just want an ability to save and reopen exactly what I&#x27;m looking at. There are some cool websites which will eventually go down and I want to preserve an interactive snapshot of them.
评论 #17308755 未加载
评论 #17309289 未加载
评论 #17308866 未加载
评论 #17308713 未加载
isuckatcoding将近 7 年前
Unrelated but There are so many things called Polly that it gets confusing
评论 #17308676 未加载
biznickman将近 7 年前
So VCR gem for javascript. Great! Personally I stopped using VCR gem a while back as it blocks edge cases. However for larger projects where things can get unwieldily this makes a lot of sense. Local test suites should never hit external APIs so it&#x27;s much better to have mocks&#x2F;stubs than to have no tests at all.<p>However on smaller projects I&#x27;ve found that just clicking through to make sure things work and then letting my error reporting system catch bugs to be much more effective :)<p>It&#x27;s a hard line to walk and I surely haven&#x27;t perfected it. I&#x27;ll give it a shot on a future project!
bookofgreg将近 7 年前
I personally replace all stubbed HTTP interactions between my services with contracts with good success. <a href="https:&#x2F;&#x2F;docs.pact.io&#x2F;getting-started" rel="nofollow">https:&#x2F;&#x2F;docs.pact.io&#x2F;getting-started</a>
textmode将近 7 年前
Alternate URL (no Javascript required):<p><a href="https:&#x2F;&#x2F;github.com&#x2F;Netflix&#x2F;pollyjs" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;Netflix&#x2F;pollyjs</a>
评论 #17309244 未加载
mygo将近 7 年前
I know this is slightly different, but I wish more people knew about Chrome &#x2F; Safari &#x2F; Firefox’s “network” console tab. Great for debugging. Can look at all requests, headers, responses, timespans, etc. Some will even let you copy a given network request as a cURL command, capturing all headers, body, query strings, etc.
评论 #17308692 未加载
ascendantlogic将近 7 年前
I&#x27;m curious what the application could be for load testing? Tools like locust and gatling are nice but are still synthetic. I&#x27;d love to capture X minutes of traffic, then dupe it Y times and replay it as a more accurate representation of traffic patterns for load testing. Is that a thing?
评论 #17338648 未加载
xab9将近 7 年前
I did something similar, but as an interim proxy (can record, replay, there are modifier hooks, can slow down requests). You have to point towards a backend api and on the frontend you use the proxy url instead of the original. But it&#x27;s mostly for debugging, so the scope is much more limited.
gnufied将近 7 年前
Also check out <a href="https:&#x2F;&#x2F;github.com&#x2F;code-mancers&#x2F;interceptor" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;code-mancers&#x2F;interceptor</a> which as well uses browser APIs to enable users to mock http responses via a chrome extension.
john838将近 7 年前
How does it hook into the browser APIs? I can&#x27;t seem to find it. By what black magic would it know how to hook into my puppeteer instance? Or I&#x27;m I not understand this?
badrelmers将近 7 年前
Why another tshark&#x2F;tcpdump? all this can be done with a simple script with few lines. Today we need javascript recorders, traffic recorders are a kid game and using a certificate to touch https is a dangerous way (but every project there is doing same). Tshark and sslkeylogfile is the only safe way... but I like this project I don&#x27;t know why! I feel something.
invisible将近 7 年前
This seems like it will be especially useful with apollo-client for graphQL requests.
Osiris将近 7 年前
I&#x27;ve used mitmproxy + proxychains to do this. How is Polly different?
评论 #17308587 未加载
swiezy2将近 7 年前
Interesting but would be more useful with support for streaming
评论 #17308586 未加载
ksejka将近 7 年前
is it a port of <a href="https:&#x2F;&#x2F;github.com&#x2F;App-vNext&#x2F;Polly" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;App-vNext&#x2F;Polly</a> ?
incadenza将近 7 年前
so this will make the actual http request the first time, then keep a recording? I’m not entirely clear how this works from the docs.
sidcool将近 7 年前
What would a use case of this library look like?
ikeboy将近 7 年前
So is this basically selenium in javascript with some neat features?
评论 #17308881 未加载
评论 #17308544 未加载
评论 #17308674 未加载
vaidik将近 7 年前
Also, what&#x27;s up with the in-your-face hiring pitch right in the documentation?<p><a href="https:&#x2F;&#x2F;netflix.github.io&#x2F;pollyjs&#x2F;#&#x2F;README?id=we39re-hiring" rel="nofollow">https:&#x2F;&#x2F;netflix.github.io&#x2F;pollyjs&#x2F;#&#x2F;README?id=we39re-hiring</a>
评论 #17312298 未加载