Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Zod error messages and user config error messages #12634

Merged
merged 13 commits into from
Dec 5, 2024
Prev Previous commit
Next Next commit
Update tests
  • Loading branch information
delucis committed Dec 4, 2024
commit 66674d697efedec0f9288d6f057dd2de9a02e2f8
15 changes: 11 additions & 4 deletions packages/astro/test/units/config/config-validate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ describe('Config Validation', () => {
assert.equal(
formattedError,
`[config] Astro found issue(s) with your configuration:
! site Expected string, received number.`,

! site Expected type "string", received "number"`,
);
});

Expand All @@ -38,8 +39,11 @@ describe('Config Validation', () => {
assert.equal(
formattedError,
`[config] Astro found issue(s) with your configuration:
! integrations.0 Expected object, received number.
! build.format Invalid input.`,

! integrations.0: Expected type "object", received "number"

! build.format: Did not match union.
> Expected "file" | "directory" | "preserve", received "invalid"`,
);
});

Expand Down Expand Up @@ -118,7 +122,10 @@ describe('Config Validation', () => {
process.cwd(),
).catch((err) => err);
assert.equal(configError instanceof z.ZodError, true);
assert.equal(configError.errors[0].message, 'Array must contain at least 1 element(s)');
assert.equal(
configError.errors[0].message,
'**i18n.locales.1.codes**: Array must contain at least 1 element(s)',
);
});

it('errors if the default locale is not in path', async () => {
Expand Down
Loading