From 35c0c2b46cc1768322f094e020fdc04413c8a9a5 Mon Sep 17 00:00:00 2001 From: Jiachi Liu Date: Mon, 6 May 2024 22:17:23 +0200 Subject: [PATCH] add react assertions --- test/e2e/module-layer/middleware.js | 4 ++++ test/e2e/module-layer/pages/api/hello.js | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/test/e2e/module-layer/middleware.js b/test/e2e/module-layer/middleware.js index 5a1050e4c6651..8a4d11761dd78 100644 --- a/test/e2e/module-layer/middleware.js +++ b/test/e2e/module-layer/middleware.js @@ -1,7 +1,11 @@ import 'server-only' +import React from 'react' import { NextResponse } from 'next/server' // import './lib/mixed-lib' export function middleware(request) { + if (React.useState) { + throw new Error('React.useState should not be defined in server layer') + } return NextResponse.next() } diff --git a/test/e2e/module-layer/pages/api/hello.js b/test/e2e/module-layer/pages/api/hello.js index b806023b05a2c..97eff319a6a64 100644 --- a/test/e2e/module-layer/pages/api/hello.js +++ b/test/e2e/module-layer/pages/api/hello.js @@ -1,5 +1,9 @@ import 'server-only' +import React from 'react' export default function handler(req, res) { + if (React.useState) { + throw new Error('React.useState should not be defined in server layer') + } return res.send('pages/api/hello.js:') }