Open jin-qin opened 3 months ago
Hey @jin-qin, thanks for reporting this issue. This behavior is a consequence of some recent work we've been doing on a VSCode extension. We should looks into better ways to detect when we are running as part of VSCode. As a immediate workaround, you can manually set the env var that triggers this behavior:
VSCODE_CWD="" yarn firebase emulators:exec "jest ${PARAMS}"
It works, thank you @joehan
Confirming that I found the same issue trying to start firebase emulators via npm script within the Ionic vscode extension, and that adding the VSCODE_CWD='' environment variable to the npm script did alleviate the issue. The npm script ran fine originally from the command line, but gave this error when executing from the Ionic vscode extension:
Error: ENOENT: no such file or directory, open '/Users/username/.nvm/versions/node/v20.16.0/lib/node_modules/firebase-tools/lib/templates/hosting/init.js'
at readFileSync (node:fs:448:20)
Here's my updated npm script:
"scripts": {
"firebase": "VSCODE_CWD='' firebase emulators:start"
},
[REQUIRED] Environment info
firebase-tools: 13.13.3
Platform: macOS Sonoma 14.5
[REQUIRED] Test case
Use Orta.vscode-jest extension, configure
firebase emulators:exec "jest"
as its command, run jest unit test.[REQUIRED] Steps to reproduce
Create a bash file say
test.sh
, and put the following content into it:settings.json
, add"jest.jestCommandLine": "./test.sh"
or put./test.sh
intoJest: Jest Command Line
in Jest extension settings.[REQUIRED] Expected behavior
Unit test is passed.
[REQUIRED] Actual behavior
Received error, test aborted:
Workaround
In fact, if I remove the following extension check in
src/templates.ts
:the issue will be suppressed and the unit test is passed.