mtbrault / nextjs-http-supertest Goto Github PK
View Code? Open in Web Editor NEWnpm package to get an http server parsing your nextJS app to link endpoint with handler
npm package to get an http server parsing your nextJS app to link endpoint with handler
I tried to use this library, but apparently, it can't handle ES Modules (ie. "type": "module"
in package.json
),.
When I tried to run it, it immediately failed after trying to require one of my (ESM) API endpoints (feedback.js
).
Error [ERR_REQUIRE_ESM]: require() of ES Module /home/me/project/next/pages/api/feedback.js from /home/me/project/next/node_modules/nextjs-http-supertest/index.js not supported.
Instead change the require of feedback.js in /home/me/project/next/node_modules/nextjs-http-supertest/index.js to a dynamic import() which is available in all CommonJS modules.
The latest commit, which has not been published to npm, breaks route resolution, as switching to foreach means nothing is returned from getDynamicRoute
itself.
is there anything I need to do to wait for the server to finish starting before I can use it?
I've just tried to implement this in a project that makes use of a monorepo. Only one of my packages requires this test. I run into the following issue:
Error handling request in nextjs-http-supertest: TypeError: Cannot destructure property 'route' of 'getDynamicRoute(...)' as it is undefined.
Upon further inspection, I find out that rootPath and thus nextPagesDirectory don't take in account mono repos. Logging them gives:
{
rootPath: '/Users/vashiru/Workspaces/my-project',
nextPagesDirectory: '/Users/vashiru/Workspaces/my-project/src/pages'
}
It should however be looking in /Users/vashiru/Workspaces/my-project/apps/web/pages
(as web is my workspace name).
There are currently no tests of this implementation. Ideally, a simple nextjs app would be tested via supertest.
I believe this would have caught the latest regression. It would also be nice to be able to extend the tests for regressions as issues are resolved.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.