代码:
should = require('should')
request = require('supertest')
request = request("stackoverflow.com");
describe "temp", ->
input_output = [
{ input:"[mocha] [supertest]", output: ["asdf", "asdf"] }
{ input:"아버지가방에들어가신다", output: [ '아버지가방에들어가신다', '아버지', '가방', '에들', '어가', '신다' ] }
{ input:"hi hello", output: ["hi", "hello"] }
]
for item in input_output
it "curl https://stackoverflow.com/search?q=#{item.input}", (done) ->
request
.get("/search?q=#{item.input}")
.expect(200)
.expect (res) ->
console.log item.input
return
.end(done)
输出:
- 温度
- 你好
- ✓ curl https://stackoverflow.com/search?q=[mocha] [supertest] (1017ms)
- 你好
- ✓ curl https://stackoverflow.com/search?q=아버지가방에들어가신다 (1023ms)
- 你好
- ✓ curl https://stackoverflow.com/search?q=hi hello (1124ms)
- 你好
我预计以下输出:
- 温度
- [摩卡] [超测]
- ✓ curl https://stackoverflow.com/search?q=[mocha] [supertest] (1017ms)
- 아버지가방에들어가신다
- ✓ curl https://stackoverflow.com/search?q=아버지가방에들어가신다 (1023ms)
- 你好
- ✓ curl https://stackoverflow.com/search?q=hi hello (1124ms)
- [摩卡] [超测]
我知道如果我在没有回调的情况下进行测试,那么我可以同步测试。但没有用。