Skip to content

Commit

Permalink
test(document): repro #7187
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Nov 2, 2018
1 parent eebfb36 commit 87005a1
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/document.test.js
Expand Up @@ -6376,4 +6376,21 @@ describe('document', function() {
assert.ok(error == null, error);
});
});

it('surfaces errors in subdoc pre validate (gh-7187)', function() {
const InnerSchema = new Schema({ name: String });

InnerSchema.pre('validate', function() {
throw new Error('Oops!');
});

const TestSchema = new Schema({ subdocs: [InnerSchema] });

const Test = db.model('gh7187', TestSchema);

return Test.create({ subdocs: [{ name: 'foo' }] }).then(
() => { throw new Error('Fail'); },
err => { assert.ok(err.message.indexOf('Oops!') !== -1, err.message); }
);
});
});

0 comments on commit 87005a1

Please sign in to comment.