Skip to content


Subversion checkout URL

You can clone with
Download ZIP


translate the Readme to Chinese #75

wants to merge 2 commits into from

2 participants


translate the Readme to Chinese


Sorry, I can't support this. I'll look into it more once the docs are revamped a bit.

@gjohnson gjohnson closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 8, 2013
  1. @lymanlai


    lymanlai authored
  2. @lymanlai


    lymanlai authored
This page is out of date. Refresh to see the latest.
Showing with 19 additions and 30 deletions.
  1. +19 −30
@@ -1,20 +1,16 @@
# SuperTest
- HTTP assertions made easy via [super-agent](
+ 通过[super-agent](来使得HTTP断言更简单。
-## About
+## 关于
- The motivation with this module is to provide a high-level abstraction for testing
- HTTP, while still allowing you to drop down to the lower-level API provided by super-agent.
+ (写)该模块的动机是为了对HTTP测试提供高层级抽象的同时也允许你使用super-agent提供的低层级API
-## Example
+## 例子
- You may pass an `http.Server`, or a `Function` to `request()` - if the server is not
- already listening for connections then it is bound to an ephemeral port for you so
- there is no need to keep track of ports.
+ 你可以传入个`http.Server``Function``request()` - 如果服务器还未监听链接则它将为你绑定到一个随机的端口这样你就不需要跟踪端口。
- SuperTest works with any test framework, here is an example without using any
- test framework at all:
+ SuperTest(可以与)任何测试框架一起工作,这里是个没有使用任何测试框架的例子:
var request = require('supertest')
@@ -36,7 +32,7 @@ request(app)
- Here's an example with mocha, note how you can pass `done` straight to any of the `.expect()` calls:
+ 这里是个与mocha(测试框架)工作的例子,注意你可以通过直接传递 `done` (参数)给任意的 `.expect()` 调用:
describe('GET /users', function(){
@@ -50,9 +46,7 @@ describe('GET /users', function(){
- If you are using the `.end()` method `.expect()` assertions that fail will
- not throw - they will return the assertion as an error to the `.end()` callback. In
- order to fail the test case, you will need to rethrow or pass `err` to `done()`, as follows:
+ 如果你是用 `.end()` 方法 `.expect()` 断言错误将会不被抛出 - 它们将断言作为错误返回给 `.end()` 回调。为了使得该测试用例错误,你需要重新抛出或传递 `err``done()`,如下所示:
describe('GET /users', function(){
@@ -69,7 +63,7 @@ describe('GET /users', function(){
- Anything you can do with superagent, you can do with supertest - for example multipart file uploads!
+ 任何你在superagent所做的,可以在supertest上做 - 例如多重文件上传!
@@ -78,9 +72,7 @@ request(app)
- Passing the app or url each time is not necessary, if you're testing
- the same host you may simply re-assign the request variable with the
- initialization app or url, a new `Test` is created per `request.VERB()` call.
+ 不需要每次都传递app或者url,如果你测试相同的主机你可以基于初始化的app或url简单的重新分配请求变量,一个新的 `Test` 将在每个 `request.VERB()` 调用时被建立。
request = request('http://localhost:5555');
@@ -96,35 +88,32 @@ request.get('/').expect('heya', function(err){
## API
- You may use any [super-agent]( methods,
- including `.write()`, `.pipe()` etc and perform assertions in the `.end()` callback
- for lower-level needs.
+ 你可以使用任何[super-agent](方法,包括 `.write()`, `.pipe()` 及在 `.end()` 回调执行低级别需求的断言。
### .expect(status[, fn])
- Assert response `status` code.
+ 断言响应 `status` 码。
### .expect(status, body[, fn])
- Assert response `status` code and `body`.
+ 断言响应 `status` 码和 `body`
### .expect(body[, fn])
- Assert response `body` text with a string, regular expression, or
- parsed body object.
+ 以一个字符串或正则表达式或解析过的body对象断言响应 `body` 文本。
### .expect(field, value[, fn])
- Assert header `field` `value` with a string or regular expression.
+ 以一个字符串或正则表达式断言头 `field` `value`
### .end(fn)
- Perform the request and invoke `fn(err, res)`.
+ 执行请求及调用 `fn(err, res)`
-## Notes
+## 备注
- Inspired by [api-easy]( minus vows coupling.
+ 灵感来自 [api-easy]( 融合少许vows。
-## License
+## 许可
Something went wrong with that request. Please try again.