How to use the firebase-functions.onCall function in firebase-functions

To help you get started, we’ve selected a few firebase-functions examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github prescottprue / fireadmin / functions / src / testRunner / index.js View on Github external
import * as functions from 'firebase-functions'
import Mocha from 'mocha'
import path from 'path'

export default functions.onCall.onRequest((req, res) => {
  // Add each .js file to the mocha instance
  // fs.readdirSync(testDir).filter(function(file){
  //     // Only keep the .js files
  //     return file.substr(-3) === '.js';
  //
  // }).forEach(function(file){
  //     mocha.addFile(
  //         path.join(testDir, file)
  //     );
  // });
  const mocha = new Mocha({
    useColors: true
  })
  mocha.addFile(path.join(__dirname, './some.js'))
  mocha.run(failures => {
    console.log('failed:', failures)