-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Closed
Description
The mocked environment config for firebase appears to only be mutable on initialization. I would like to be able to modify the config for various mocha tests and test different configurations of the code. Here is an example
const chai = require('chai')
const test = require('firebase-functions-test')()
const functions = require('firebase-functions')
describe('All Tests', () => {
describe('Test1', () => {
before(function () {
const config = {
site: {
url: 'https://site1.com'
}
}
test.mockConfig(config)
})
it('Run Test', async () => {
console.log(functions.config().site.url)
// ...
})
after(() => {
test.cleanup()
})
})
describe('Test2', () => {
before(function () {
const config = {
site: {
url: 'https://site2.com'
}
}
test.mockConfig(config)
})
it('Run Test', async () => {
console.log(functions.config().site.url)
})
after(() => {
test.cleanup()
})
})
})
The config in 'Test 2' will match that of 'Test 1'. My hope was that test.cleanup()
would reset the mocked state and allow it to be changed in further tests. Instead, you will see this output
All Tests
Test1
https://site1.com
✓ Run Test
Test2
https://site1.com
✓ Run Test
2 passing (12ms)
Metadata
Metadata
Assignees
Labels
No labels