-
Notifications
You must be signed in to change notification settings - Fork 4
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
fix: error when trying to save mock request file that doesn't exist #11
Conversation
src/apiCache.ts
Outdated
if (err && err.code !== 'ENOENT') { | ||
// eslint-disable-next-line | ||
console.log({ err }); | ||
} |
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 that this not is the best solution for your problem
Try to find the root cause
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.
hi @nogw thanks for the pull request
can you also add an improvement to create the mock JSON file when it does not exist before saving it?
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.
Check if the file exists with fs.existsSync
instead
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.
check the fs opening of writemock
done, using |
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.
Nice! Good fix
Description
As mentioned in issue #10, if the file "mock-requests.json" does not exist and you run the command "WRITE_MOCK=true yarn es scripts/test.ts", an error message will be shown, however, the file is created in any case
Changes
Related Issues