diff --git a/src/build/verification.ts b/src/build/verification.ts index a4089349d5..a35bd85bda 100644 --- a/src/build/verification.ts +++ b/src/build/verification.ts @@ -113,13 +113,13 @@ export async function verifyNetlifyFormsWorkaround(ctx: PluginContext) { export function verifyNetlifyForms(ctx: PluginContext, html: string) { if ( - !verifications.has('netlifyForms') && + process.env.NETLIFY_NEXT_VERIFY_FORMS !== '0' && + process.env.NETLIFY_NEXT_VERIFY_FORMS?.toUpperCase() !== 'FALSE' && !verifications.has('netlifyFormsWorkaround') && formDetectionRegex.test(html) ) { - console.warn( + ctx.failBuild( '@netlify/plugin-nextjs@5 requires migration steps to support Netlify Forms. Refer to https://ntl.fyi/next-runtime-forms-migration for migration example.', ) - verifications.add('netlifyForms') } } diff --git a/tests/integration/netlify-forms.test.ts b/tests/integration/netlify-forms.test.ts index 728c377d74..0087d5d9ca 100644 --- a/tests/integration/netlify-forms.test.ts +++ b/tests/integration/netlify-forms.test.ts @@ -19,24 +19,24 @@ beforeEach(async (ctx) => { await startMockBlobStore(ctx) }) -it('should warn when netlify forms are used', async (ctx) => { +it('should fail build when netlify forms are used', async (ctx) => { const warn = vi.spyOn(console, 'warn').mockImplementation(() => {}) await createFixture('netlify-forms', ctx) - const runPluginPromise = await runPlugin(ctx) + const runPluginPromise = runPlugin(ctx) - expect(warn).toBeCalledWith( + await expect(runPluginPromise).rejects.toThrow( '@netlify/plugin-nextjs@5 requires migration steps to support Netlify Forms. Refer to https://ntl.fyi/next-runtime-forms-migration for migration example.', ) }) -it('should not warn when netlify forms are used with workaround', async (ctx) => { +it('should not fail build when netlify forms are used with workaround', async (ctx) => { const warn = vi.spyOn(console, 'warn').mockImplementation(() => {}) await createFixture('netlify-forms-workaround', ctx) - const runPluginPromise = await runPlugin(ctx) + const runPluginPromise = runPlugin(ctx) - expect(warn).not.toBeCalled() + await expect(runPluginPromise).resolves })