-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add unit tests and refactor nextjs build adaptor to make testing easier #131
Conversation
Yuangwang
commented
Dec 15, 2023
- adds unit tests for nextjs adaptor
- refactors out functions to util directory
- formatted a couple other files nearby
|
||
// move the standalone directory, the static directory and the public directory to apphosting output directory | ||
// as well as generating bundle.yaml | ||
export async function generateOutputBundle( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this naming is too similar to "generateBundleYaml" and could get confusing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed it to "generateOutputDirectory"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the major logic for the build adaptor should be mainly in the build file and have some helper functions in utils, rn it seems like all the logic are in utils.ts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I needed to extract the functions out into utils.ts for the code to be testable.
The way that imports work right now is that when you import a file ( for example const importUtils = import("@apphosting/adapter-nextjs/dist/utils.js")) the imported file will be run in its entirety. In our case we don't actually want the whole of build.ts to be run since it will not work properly as it expected to be run in a nextjs app and not this repo.
We don't want build.ts to be run but we still want to be able to import the functions that need to be unit tested so I needed to extract those functions out to a separate file that is okay to be run in its entirety. In this case that is utils.ts