Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/build/verification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}
}
12 changes: 6 additions & 6 deletions tests/integration/netlify-forms.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,24 @@ beforeEach<FixtureTestContext>(async (ctx) => {
await startMockBlobStore(ctx)
})

it<FixtureTestContext>('should warn when netlify forms are used', async (ctx) => {
it<FixtureTestContext>('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<FixtureTestContext>('should not warn when netlify forms are used with workaround', async (ctx) => {
it<FixtureTestContext>('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
})