我有一个REST API,我的一个测试需要某些资源由另一个API创建...下面的示例演示了模式..问题是
其他推荐方法?
userTest.js
exports.createAdminUser = function(done) {
request.post( ... );
expect(res.location).to.eql(...);
// Now I've created an admin user
};
describe('User Tests', function() {
it('creates an admin user', createAdminUser);
it('modifies the admin user', ...);
...
}
我还有另一个帐户测试,必须有用户设置。我不想再为这些类型的依赖测试再次做这项工作
Accounts Test
-------------
var userTests = require('../users/userTest.js');
describe('Account Tests', function() {
it('creates an admin user to prime the database', userTests.createAdminUser);
it('creates a checking account', function(done){
// Here I need to know the ID of the admin user to use in my POST req.
});
}