forked from firebase/firebase-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
extensions functional test update (firebase#2181)
* use shared testing framework for tests * remove AndWait function * link global module and run test file
- Loading branch information
Showing
7 changed files
with
107 additions
and
308 deletions.
There are no files selected for viewing
This file contains 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 @@ | ||
package-lock.json |
This file contains 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,12 +1,15 @@ | ||
#!/bin/bash | ||
|
||
set -e # Immediately exit on failure | ||
|
||
# Globally link the CLI for the testing framework. | ||
npm link | ||
|
||
cd scripts/extensions-emulator-tests/greet-the-world | ||
npm i | ||
cd - # Return to root so that we don't need a relative path for mocha | ||
|
||
mocha \ | ||
--require ts-node/register \ | ||
--require source-map-support/register \ | ||
--require src/test/helpers/mocha-bootstrap.js \ | ||
scripts/extensions-emulator-tests/test.spec.ts | ||
scripts/extensions-emulator-tests/tests.ts |
This file was deleted.
Oops, something went wrong.
This file contains 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,62 @@ | ||
import { expect } from "chai"; | ||
import * as fs from "fs"; | ||
import * as path from "path"; | ||
import * as subprocess from "child_process"; | ||
|
||
import { FrameworkOptions, TriggerEndToEndTest } from "../integration-helpers/framework"; | ||
|
||
const EXTENSION_ROOT = path.dirname(__filename) + "/greet-the-world"; | ||
|
||
const FIREBASE_PROJECT = process.env.FBTOOLS_TARGET_PROJECT || ""; | ||
const FIREBASE_PROJECT_ZONE = "us-east1"; | ||
const TEST_CONFIG_FILE = "test-firebase.json"; | ||
const TEST_FUNCTION_NAME = "greetTheWorld"; | ||
|
||
/* | ||
* Various delays that are needed because this test spawns | ||
* parallel emulator subprocesses. | ||
*/ | ||
const TEST_SETUP_TIMEOUT = 60000; | ||
const EMULATORS_SHUTDOWN_DELAY_MS = 5000; | ||
|
||
function readConfig(): FrameworkOptions { | ||
const filename = path.join(EXTENSION_ROOT, "test-firebase.json"); | ||
const data = fs.readFileSync(filename, "utf8"); | ||
return JSON.parse(data); | ||
} | ||
|
||
describe("extension emulator", () => { | ||
let test: TriggerEndToEndTest; | ||
|
||
before(async function() { | ||
this.timeout(TEST_SETUP_TIMEOUT); // eslint-disable-line no-invalid-this | ||
|
||
expect(FIREBASE_PROJECT).to.exist.and.not.be.empty; | ||
|
||
// TODO(joehan): Delete the --open-sesame call when extdev flag is removed. | ||
const p = subprocess.spawnSync("firebase", ["--open-sesame", "extdev"], { cwd: __dirname }); | ||
console.log("open-sesame output:", p.stdout.toString()); | ||
|
||
test = new TriggerEndToEndTest(FIREBASE_PROJECT, EXTENSION_ROOT, readConfig()); | ||
await test.startExtEmulators([ | ||
"--test-params", | ||
"test-params.env", | ||
"--test-config", | ||
TEST_CONFIG_FILE, | ||
]); | ||
}); | ||
|
||
after(async function() { | ||
this.timeout(EMULATORS_SHUTDOWN_DELAY_MS); // eslint-disable-line no-invalid-this | ||
await test.stopEmulators(); | ||
}); | ||
|
||
it("should execute an HTTP function", async function() { | ||
this.timeout(EMULATORS_SHUTDOWN_DELAY_MS); // eslint-disable-line no-invalid-this | ||
|
||
const res = await test.invokeHttpFunction(TEST_FUNCTION_NAME, FIREBASE_PROJECT_ZONE); | ||
|
||
expect(res.statusCode).to.equal(200); | ||
expect(res.body).to.equal("Hello World from greet-the-world"); | ||
}); | ||
}); |
File renamed without changes.
Oops, something went wrong.