How to remove files and folders with a name pattern recursively?
Customize HTML in Jest
In some scenarios, you may want to customize the HTML in Jest to align with your actual app's HTML structure. You can do it by one of the following options:
How long files stay in temporary folder
How long files stay in temporary folder?
Usually 3 days if a file hasn't been accessed. It depends on OS.
Cannot run gpg No such file or directory
git -c user.useConfigOnly=true commit --quiet --allow-empty-message --file - error: cannot run gpg: No such file or directory error: gpg failed to sign the data fatal: failed to write commit object
Answer:
git config --global gpg.program "$(which gpg)"
Use pnpm with Gatsby
I recently migrated my Gatsby project from yarn to pnpm. So in this post I will go over quickly what needs to be done to get it working.
You can see the full PR that I migrate my project to pnpm here: https://github.com/nvh95/hung.dev/pull/62
Sharp error mac m1
When running command yarn
to install dependencies for a Gatsby project on Mac M1, I encounter this error with sharp
:
Convert to mp3 using ffmpeg
You can convert audio/ video files to mp3 format using ffmpeg by:
ffmpeg -i input.mov -c:v copy -c:a libmp3lame -q:a 4 output.mp3
This is handy when you trim the video/ audio when using QuickTime on macOS (since the extension will be .mov
or .m4a
)
Link to specific time in mp3 file via query string
You can link to any specific time in a mp3 file, just by adding a query string #t=<time>
to the mp3 file url.
For example, if you want to link to 18:15 of a mp3 file, 18*60 + 15 = 2295
, you can use the url https://cdn.changelog.com/uploads/jsparty/231/js-party-231.mp3#t=2295.
Reference: Jest Preview on JS Party Podcast
Error Application-specific password required
If you want to add an alias to send an email from a different email address. You might end up following this tutorial:
But you might encounter this issue: [AUTH] Application-specific password required.
Dream Frontend Test Stack
This is my dream frontend test stack, to test my React applications:
- Jest: Jest is a delightful JavaScript Testing Framework with a focus on simplicity. https://jestjs.io
- React Testing Library: To render the app "as real as possible", but in JSDOM https://testing-library.com/docs/react-testing-library/intro
- User event: To interactive with the app (usually rendered by React Testing Library) as a normal user https://testing-library.com/docs/user-event/intro
- msw: To eliminate all the API mocking at the app level.
msw
mocks your API requests at the network level. You just write the actual code that calls API,msw
will act as a real server. We can re-usemsw
for development and writing tests. https://mswjs.io - jest-preview: To preview the app when testing with Jest. No more looking at HTML on Terminal, just a beautiful UI in the browser. https://www.jest-preview.com