๐๐ผ๐ Node.js ๐๐ถ๐ป๐ฑ๐ ๐ฎ ๐ฃ๐ฟ๐ผ๐ท๐ฒ๐ฐ๐ ๐๐ถ๐น๐ฒ ๐ณ๐ฟ๐ผ๐บ ๐๐ต๐ฒ ๐ฆ๐ฐ๐ฟ๐ถ๐ฝ๐?
๐ฃ๐ฟ๐ผ๐ฏ๐น๐ฒ๐บ ๐ฆ๐๐ฎ๐๐ฒ๐บ๐ฒ๐ป๐:
A hardcoded path such as C:\Users\XYZ\Downloads\ABC\fixtures\accounts.json names this PC and this Downloads folder. Move the project, and readFileSync still looks there, so it cannot open accounts.json.
๐ฆ๐ผ๐น๐๐๐ถ๐ผ๐ป:
Build the path from the script file with join(dirname(fileURLToPath(import.meta.url)), '../fixtures/accounts.json'). Node starts at the script, goes up one folder, and enters fixtures, wherever the project sits.
#SQA #NODE #Automation #testing
https://www.youtube.com/watch?v=DXDxhXfmqPs