Skip to content

Commit ece6b5d

Browse files
committed
test: rename edge-handler to middleware now that node middleware is tested there
1 parent 959afb4 commit ece6b5d

File tree

1 file changed

+58
-16
lines changed

1 file changed

+58
-16
lines changed

tests/integration/edge-handler.test.ts renamed to tests/integration/middleware.test.ts

Lines changed: 58 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,23 @@ for (const {
2626
edgeFunctionNameRoot,
2727
edgeFunctionNameSrc,
2828
expectedRuntime,
29+
isNodeMiddleware,
2930
label,
3031
runPluginConstants,
3132
} of [
3233
{
3334
edgeFunctionNameRoot: EDGE_MIDDLEWARE_FUNCTION_NAME,
3435
edgeFunctionNameSrc: EDGE_MIDDLEWARE_SRC_FUNCTION_NAME,
3536
expectedRuntime: 'edge-runtime',
37+
isNodeMiddleware: false,
3638
label: 'Edge runtime middleware',
3739
},
3840
hasNodeMiddlewareSupport()
3941
? {
4042
edgeFunctionNameRoot: NODE_MIDDLEWARE_FUNCTION_NAME,
4143
edgeFunctionNameSrc: NODE_MIDDLEWARE_FUNCTION_NAME,
4244
expectedRuntime: 'node',
45+
isNodeMiddleware: true,
4346
label: 'Node.js runtime middleware',
4447
runPluginConstants: { PUBLISH_DIR: '.next-node-middleware' },
4548
}
@@ -692,25 +695,64 @@ for (const {
692695
expect(bodyFr.nextUrlLocale).toBe('fr')
693696
})
694697
})
698+
699+
if (isNodeMiddleware) {
700+
describe('Node.js Middleware specific', () => {
701+
test.only<FixtureTestContext>('should fail to deploy when using unsupported C++ Addons with meaningful message about limitation', async (ctx) => {
702+
await createFixture('middleware-node-unsupported-cpp-addons', ctx)
703+
704+
const runPluginPromise = runPlugin(ctx)
705+
await runPluginPromise
706+
707+
const origin = await LocalServer.run(async (req, res) => {
708+
res.write(
709+
JSON.stringify({
710+
url: req.url,
711+
headers: req.headers,
712+
}),
713+
)
714+
res.end()
715+
})
716+
ctx.cleanup?.push(() => origin.stop())
717+
const response = await invokeEdgeFunction(ctx, {
718+
functions: [edgeFunctionNameRoot],
719+
origin,
720+
url: `/json`,
721+
})
722+
console.log(response)
723+
724+
// await expect(runPluginPromise).rejects.toThrow('Node.js middleware is not yet supported.')
725+
// await expect(runPluginPromise).rejects.toThrow(
726+
// 'Future @netlify/plugin-nextjs release will support node middleware with following limitations:',
727+
// )
728+
// await expect(runPluginPromise).rejects.toThrow(
729+
// ' - usage of C++ Addons (https://nodejs.org/api/addons.html) not supported (for example `bcrypt` npm module will not be supported, but `bcryptjs` will be supported)',
730+
// )
731+
// await expect(runPluginPromise).rejects.toThrow(
732+
// ' - usage of Filesystem (https://nodejs.org/api/fs.html) not supported',
733+
// )
734+
})
735+
})
736+
}
695737
})
696738
}
697739

698740
// test.skipIf(!nextVersionSatisfies('>=15.2.0'))<FixtureTestContext>(
699741
// 'should throw an Not Supported error when node middleware is used',
700-
// async (ctx) => {
701-
// await createFixture('middleware-node', ctx)
702-
703-
// const runPluginPromise = runPlugin(ctx)
704-
705-
// await expect(runPluginPromise).rejects.toThrow('Node.js middleware is not yet supported.')
706-
// await expect(runPluginPromise).rejects.toThrow(
707-
// 'Future @netlify/plugin-nextjs release will support node middleware with following limitations:',
708-
// )
709-
// await expect(runPluginPromise).rejects.toThrow(
710-
// ' - usage of C++ Addons (https://nodejs.org/api/addons.html) not supported (for example `bcrypt` npm module will not be supported, but `bcryptjs` will be supported)',
711-
// )
712-
// await expect(runPluginPromise).rejects.toThrow(
713-
// ' - usage of Filesystem (https://nodejs.org/api/fs.html) not supported',
714-
// )
715-
// },
742+
// async (ctx) => {
743+
// await createFixture('middleware-node', ctx)
744+
745+
// const runPluginPromise = runPlugin(ctx)
746+
747+
// await expect(runPluginPromise).rejects.toThrow('Node.js middleware is not yet supported.')
748+
// await expect(runPluginPromise).rejects.toThrow(
749+
// 'Future @netlify/plugin-nextjs release will support node middleware with following limitations:',
750+
// )
751+
// await expect(runPluginPromise).rejects.toThrow(
752+
// ' - usage of C++ Addons (https://nodejs.org/api/addons.html) not supported (for example `bcrypt` npm module will not be supported, but `bcryptjs` will be supported)',
753+
// )
754+
// await expect(runPluginPromise).rejects.toThrow(
755+
// ' - usage of Filesystem (https://nodejs.org/api/fs.html) not supported',
756+
// )
757+
// },
716758
// )

0 commit comments

Comments
 (0)