有人可以向我解释为什么会发生以下情况..
我有一个测试快递路线的代码:
request = require 'supertest'
express = require 'express'
app = express()
Authentication = require("#{specDir}/../apps/authentication/routes")
authenticate = new Authentication app
describe 'authentication routes', ->
describe 'GET', ->
describe '/', ->
describe 'user not logged in', ->
requested = request(app).get('/').set('Accept', 'application/json')
describe 'application/json', ->
it 'sends error mesage', (done) ->
request(app).get('/').set('Accept', 'application/json').end (err, res) ->
expect(res.body).to.have.deep.property 'error.message', 'you need to log in'
done()
it 'sends 401 status', (done) ->
request(app).get('/').set('Accept', 'application/json').end (err, res) ->
expect(res.statusCode).to.equal 401
done()
该代码可以正常工作,测试通过。但是,如果我将它request(app).get('/').set('Accept', 'application/json')
与requested
变量交换,第一个测试将通过,第二个将超时。
这是为什么?