Для каждого вложенного describe
я хочу выполнить следующую последовательность:
before
-> создать учетную запись it
-> запустить тесты after
-> удаляет созданную учетную запись
Моя проблема в том, что хук after
запускается только после выполнения всех describe
вместо того, чтобы запускаться для каждого describe
.
Как запустить тесты в последовательности, указанной выше?
let res;
const randomAccount = {
'email': 'automation17@yahoo.com',
'password': '123456',
};
describe('Create accounts with email and password', function() {
describe('should create a valid account', function() {
before(function() {
return accountsHelper.createNewAccount(randomAccount)
.then(function(response) {
res = response;
});
});
it('should return status code 200', function(done) {
expect(res.status).to.equal(commonData.statusCode.ok);
done();
});
it('should return response', function(done) {
expect(res.body.admin).to.equal(false);
done();
});
after(function() {
return accountsHelper.deleteAccount();
});
});
describe('should create an invalid account', function() {
before(function() {
return accountsHelper.createNewAccount(randomAccount)
.then(function(response) {
res = response;
});
});
it('should return response', function(done) {
expect(res.body.admin).to.equal(false);
done();
});
after(function() {
return accountsHelper.deleteAccount();
});
});
});