Skip to content

Commit e91d404

Browse files
committedJul 29, 2018
test(transactions): skip nested suite if parent suite skipped
Re: #6754
1 parent 22c6c33 commit e91d404

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed
 

‎test/docs/transactions.test.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const Schema = mongoose.Schema;
88

99
describe('transactions', function() {
1010
let db;
11+
let _skipped = false;
1112

1213
before(function() {
1314
db = start({ replicaSet: 'rs' });
@@ -16,6 +17,7 @@ describe('transactions', function() {
1617
then(() => {
1718
// Skip if not a repl set
1819
if (db.client.topology.constructor.name !== 'ReplSet') {
20+
_skipped = true;
1921
this.skip();
2022
}
2123
}).
@@ -29,11 +31,13 @@ describe('transactions', function() {
2931
})).
3032
then(version => {
3133
if (version[0] < 4) {
34+
_skipped = true;
3235
this.skip();
3336
}
3437
}).
3538
catch(() => {
36-
this.skip()
39+
_skipped = true;
40+
this.skip();
3741
});
3842
});
3943

@@ -155,17 +159,26 @@ describe('transactions', function() {
155159
});
156160

157161
beforeEach(function() {
162+
if (_skipped) {
163+
return this.skip(); // https://github.com/mochajs/mocha/issues/2546
164+
}
158165
return Author.deleteMany({}).then(() => Article.deleteMany({}));
159166
});
160167

161168
beforeEach(function() {
169+
if (_skipped) {
170+
return this.skip(); // https://github.com/mochajs/mocha/issues/2546
171+
}
162172
return db.startSession().then(_session => {
163173
session = _session;
164174
session.startTransaction();
165175
});
166176
});
167177

168178
afterEach(function() {
179+
if (_skipped) {
180+
return; // https://github.com/mochajs/mocha/issues/2546
181+
}
169182
return session.commitTransaction();
170183
});
171184

0 commit comments

Comments
 (0)
Please sign in to comment.