Skip to content

Commit

Permalink
test(transactions): skip nested suite if parent suite skipped
Browse files Browse the repository at this point in the history
Re: #6754
  • Loading branch information
vkarpov15 committed Jul 29, 2018
1 parent 22c6c33 commit e91d404
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion test/docs/transactions.test.js
Expand Up @@ -8,6 +8,7 @@ const Schema = mongoose.Schema;

describe('transactions', function() {
let db;
let _skipped = false;

before(function() {
db = start({ replicaSet: 'rs' });
Expand All @@ -16,6 +17,7 @@ describe('transactions', function() {
then(() => {
// Skip if not a repl set
if (db.client.topology.constructor.name !== 'ReplSet') {
_skipped = true;
this.skip();
}
}).
Expand All @@ -29,11 +31,13 @@ describe('transactions', function() {
})).
then(version => {
if (version[0] < 4) {
_skipped = true;
this.skip();
}
}).
catch(() => {
this.skip()
_skipped = true;
this.skip();
});
});

Expand Down Expand Up @@ -155,17 +159,26 @@ describe('transactions', function() {
});

beforeEach(function() {
if (_skipped) {
return this.skip(); // https://github.com/mochajs/mocha/issues/2546
}
return Author.deleteMany({}).then(() => Article.deleteMany({}));
});

beforeEach(function() {
if (_skipped) {
return this.skip(); // https://github.com/mochajs/mocha/issues/2546
}
return db.startSession().then(_session => {
session = _session;
session.startTransaction();
});
});

afterEach(function() {
if (_skipped) {
return; // https://github.com/mochajs/mocha/issues/2546
}
return session.commitTransaction();
});

Expand Down

0 comments on commit e91d404

Please sign in to comment.