1

I'm running some React integration tests with npm, and need the Firebase emulator for them. I've set up my npm scripts as follows:

"scripts": {
 "test:integration:runner": "cross-env RTL_SKIP_AUTO_CLEANUP=true FIREBASE_DATABASE_EMULATOR_HOST=\"localhost:9000\" FIREBASE_FUNCTIONS_EMULATOR_HOST=\"localhost:5001\" FIREBASE_AUTH_EMULATOR_HOST=\"localhost:9099\" react-scripts test ./src/integrationTests/App.spec.js --watchAll=false",
 "test:integration": "firebase emulators:exec 'npm run test:integration:runner'",
 },

However, when I run npm run test:integration, the script returns after about 1 second, with no errors. Here is the only ouput:

PS C:\Users\{userame}\{project}> npm run test:integration
> {project_name} test:integration
> firebase emulators:exec 'npm run test:integration:runner' 
PS C:\Users\{userame}\{project}>

The firebase emulator itself is working if I run it standalone, and I tested the integration test with the emulator already running, and that works as well. I tried running firebase emulators:exec with a different non-npm script (instead of npm run test:integration:runner) and it successfully spun up the emulator. Any idea what might be happening here?

asked Jul 15, 2022 at 21:30

1 Answer 1

2

Well, I figured this out soon after asking the question. It turns out you need to double quote the script.

So I changed

"test:integration": "firebase emulators:exec 'npm run test:integration:runner'",

to

"test:integration": "firebase emulators:exec \"npm run test:integration:runner\" ",

I'd like to understand why this works though. This is in Windows, and I'm not sure how single/double quote semantics in commands might differ from what I'm used to.

answered Jul 15, 2022 at 21:35
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for reporting the fix. This was driving me crazy. Single quotes work on my Mac but not my Windows box, where I run Git Bash. Maybe related to stackoverflow.com/a/37501023/4564359 ?

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.