-
Notifications
You must be signed in to change notification settings - Fork 213
Add integration test for firebase-functions binary #1028
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
af6ed7e
Add integration test for firebase-functions binary.
taeold e58acbd
Minor fixes.
taeold 6f6a298
Run the new integration test on PR and in release script.
taeold 3827c07
Merge branch 'master' of https://github.com/firebase/firebase-functio…
taeold c1683e8
Make cleanup call robust.
taeold ef716d2
Breakout integration test as its own workflow.
taeold 1f16178
Correctly breakout integration tests.
taeold cd20c24
Temporarily add debug message to help debug ci test issues.
taeold 31d3506
Try not using sudo npm link.
taeold 3767b61
Fix integration test in CI env.
taeold efea051
Merge branch 'master' into dl-integration-tests
taeold File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,8 @@ | ||
exit: true | ||
extension: | ||
- ts | ||
file: | ||
- mocha/setup.ts | ||
package: ./package.json | ||
reporter: spec | ||
require: | ||
- 'ts-node/register' | ||
spec: spec/**/*.spec.ts | ||
- 'source-map-support/register' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import * as chai from 'chai'; | ||
import * as chaiAsPromised from 'chai-as-promised'; | ||
|
||
chai.use(chaiAsPromised); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
set -ex # Immediately exit on failure | ||
|
||
# Link the Functions SDK for the testing environment. | ||
npm run build | ||
npm link | ||
|
||
# Link local SDK to all test sources. | ||
for f in scripts/bin-test/sources/*; do | ||
if [ -d "$f" ]; then | ||
(cd "$f" && npm link firebase-functions) | ||
fi | ||
done | ||
|
||
## DEBUG | ||
ls -la scripts/bin-test/sources/commonjs/node_modules | ||
|
||
mocha \ | ||
--file ./scripts/bin-test/mocha-setup.ts \ | ||
./scripts/bin-test/test.ts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const functions = require("firebase-functions"); | ||
|
||
exports.groupedhttp = functions.https.onRequest((req, resp) => { | ||
resp.status(200).send("PASS"); | ||
}); | ||
|
||
exports.groupedcallable = functions.https.onCall(() => { | ||
return "PASS"; | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
const functions = require("firebase-functions"); | ||
const functionsv2 = require("firebase-functions/v2"); | ||
|
||
exports.v1http = functions.https.onRequest((req, resp) => { | ||
resp.status(200).send("PASS"); | ||
}); | ||
|
||
exports.v1callable = functions.https.onCall(() => { | ||
return "PASS"; | ||
}); | ||
|
||
exports.v2http = functionsv2.https.onRequest((req, resp) => { | ||
resp.status(200).send("PASS"); | ||
}); | ||
|
||
exports.v2callable = functionsv2.https.onCall(() => { | ||
return "PASS"; | ||
}); | ||
|
||
exports.g1 = require("./g1"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"name": "commonjs-grouped" | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const functions = require("firebase-functions"); | ||
const functionsv2 = require("firebase-functions/v2"); | ||
|
||
exports.v1http = functions.https.onRequest((req, resp) => { | ||
resp.status(200).send("PASS"); | ||
}); | ||
|
||
exports.v1callable = functions.https.onCall(() => { | ||
return "PASS"; | ||
}); | ||
|
||
exports.v2http = functionsv2.https.onRequest((req, resp) => { | ||
resp.status(200).send("PASS"); | ||
}); | ||
|
||
exports.v2callable = functionsv2.https.onCall(() => { | ||
return "PASS"; | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"name": "commonjs-main", | ||
"main": "functions.js" | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const functions = require("firebase-functions"); | ||
const functionsv2 = require("firebase-functions/v2"); | ||
|
||
exports.v1http = functions.https.onRequest((req, resp) => { | ||
resp.status(200).send("PASS"); | ||
}); | ||
|
||
exports.v1callable = functions.https.onCall(() => { | ||
return "PASS"; | ||
}); | ||
|
||
exports.v2http = functionsv2.https.onRequest((req, resp) => { | ||
resp.status(200).send("PASS"); | ||
}); | ||
|
||
exports.v2callable = functionsv2.https.onCall(() => { | ||
return "PASS"; | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"name": "commonjs" | ||
} |
4 changes: 2 additions & 2 deletions
4
spec/fixtures/sources/esm-ext/index.mjs → scripts/bin-test/sources/esm-ext/index.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
spec/fixtures/sources/esm-main/functions.js → ...ts/bin-test/sources/esm-main/functions.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
spec/fixtures/sources/esm/index.js → scripts/bin-test/sources/esm/index.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
removing this just means that we now have test files outside the
spec/
dir and they don't need spec in the title, correct?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.
Yes - having the spec defined here made it impossible for me to not run them for integration tests. So we now pass in the path/glob of test we want to run in the npm script definition (in package.json) itself.
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.
Ahhh the changed line -
"test": "mocha --file ./mocha/setup.ts spec/**/*.spec.ts ",
. Thanks!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.
Hmm... there's no other way to achieve our goal? Changing mocha to need a --file means that running an individual file's tests with
npx mocha
got harder.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.
Hmm don't you still need to pass individual file via
npx mocha
, e.g.npx mocha spec/path/to/my/test.ts
?I'm not sure what devx I just broke here. I don't know if other ways exists, but happy to explore.