ng-apimock / core

ng-apimock core module
MIT License
34 stars 20 forks source link

Logging Error > ENOENT: no such file or directory #421

Closed ReinderR001 closed 3 years ago

ReinderR001 commented 3 years ago

Hello Mischa,

The added debug logging is helpful for troubleshooting. Thanks a lot!

When a mockfile contains a path to file/directory that not exists the code returns an error in the message. It would be helpfull when this message also would be added to the debug log.

By adding exports.log(e.message); in /middleware/handlers/mock/mock.request.handler.js:43 i receive the logging like:
ng-apimock: handler-request ENOENT: no such file or directory, open 'e2e\mocks\fileNotExists.json'

mdasberg commented 3 years ago

@ReinderR001 can you show me your mock.json file that contains the fileNotExists.json ?

ReinderR001 commented 3 years ago

@mdasberg I received te message that this issues was closed. That triggert me that i hadn't reply your question. A mock.json for example that contains a filePath. { "name": "getCategorie", "request": { "url": ".*/categorie$", "method": "GET" }, "responses": { "standaard": { "default": true, "file": "e2e/testdata/categorie.json", "headers": { "Content-Type": "application/json;charset=UTF-8", "Access-Control-Allow-Origin": "*" }, "status": 200, } } } If the file e2e/testdata/categorie.json doesn't exists, the current logging doesn't contain a message that the file isn't found. The suggestion is to add exports.log(e.message); in /middleware/handlers/mock/mock.request.handler.js:43. Then i receive a errorlog like: ng-apimock: handler-request ENOENT: no such file or directory, open 'e2e/testdata/categorie.json'

mdasberg commented 3 years ago

@ReinderR001 I reopened the ticket. Let me see if I can replay it locally

mdasberg commented 3 years ago

The file location should be relative so you can just put "file": "categorie.json" in @ReinderR001 could you verify?

ReinderR001 commented 3 years ago

Hi Misha, i think we've got a misunderstanding. It isn't a problem to add a file to the mock. That's working fine. But in case you make a typo in the mock.json, for example "file": "categorie.json" where the file is named "category.json" it would be helpfull when the error message would tell "no such file or directory, open 'e2e\mocks\categorie.json'.

mdasberg commented 3 years ago

ah, yes, now I get it :)

mdasberg commented 3 years ago

:tada: This issue has been resolved in version 3.0.2 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

mdasberg commented 3 years ago

:tada: This issue has been resolved in version 3.0.3 :tada:

The release is available on:

Your semantic-release bot :package::rocket: