Skip to content

test(document): enable and fix skipped pathsToSkip test#16011

Merged
vkarpov15 merged 2 commits intoAutomattic:masterfrom
Divyapahuja31:fix/model-validate-paths-to-skip
Feb 6, 2026
Merged

test(document): enable and fix skipped pathsToSkip test#16011
vkarpov15 merged 2 commits intoAutomattic:masterfrom
Divyapahuja31:fix/model-validate-paths-to-skip

Conversation

@Divyapahuja31
Copy link

Summary

This PR enables a test case for Model.validate() with the pathsToSkip option that was previously skipped with a "TODO" comment.

The test was originally skipped because the implementation was incorrect; it attempted to await User.validate() without catching the rejected Promise that occurs during a validation error. This caused the test to crash instead of asserting the error contents.

I have updated the test to correctly handle the Promise rejection and assert that the correct validation errors are returned, verifying that the pathsToSkip feature works as intended for Model.validate().

Examples

Before (Skipped):

it.skip('support `pathsToSkip` option for `Model.validate()`', async function() {
  const User = getUserModel();
  const err1 = await User.validate({}, { pathsToSkip: ['age'] });
  assert.deepEqual(Object.keys(err1.errors), ['name']);
});

After (Enabled & Fixed):

it('support `pathsToSkip` option for `Model.validate()`', async function() {
  const User = getUserModel();
  const err1 = await User.validate({}, { pathsToSkip: ['age'] }).then(() => null, err => err);
  assert.deepEqual(Object.keys(err1.errors), ['name']);
  
  const err2 = await User.validate({}, { pathsToSkip: ['name'] }).then(() => null, err => err);
  assert.deepEqual(Object.keys(err2.errors), ['age']);
});

Copy link
Collaborator

@AbdelrahmanHafez AbdelrahmanHafez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test file has so many unrelated formatting changes that make it really difficult to review, can you please revert these changes?

@Divyapahuja31
Copy link
Author

Divyapahuja31 commented Feb 5, 2026

apologies for the unrelated formatting changes in the previous commit, i have fixed that formatting changes now it will be much easier to review it

@Divyapahuja31 Divyapahuja31 force-pushed the fix/model-validate-paths-to-skip branch from 3d2d67b to 83848ea Compare February 5, 2026 14:33
Copy link
Collaborator

@AbdelrahmanHafez AbdelrahmanHafez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks! 👍

Copy link
Collaborator

@vkarpov15 vkarpov15 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 👍

@vkarpov15 vkarpov15 merged commit d41eb97 into Automattic:master Feb 6, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants