Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
Activa una función cuando finalice una matriz de pruebas
Crea una función nueva que se active cuando una matriz de prueba se complete con el controlador de eventos functions.testLab.testMatrix().onComplete():
Las matrices de pruebas se pueden crear a partir de diferentes fuentes o flujos de trabajo. Por lo tanto, a menudo se recomienda crear funciones que realicen acciones distintas basadas en la fuente o en otro contexto importante de la prueba. Para ayudarte con esto, cuando inicies una prueba, gcloud te permitirá pasar información arbitraria a la que puedas acceder más adelante en la función. Por ejemplo:
gcloud beta firebase test android run \
--app=path/to/app.apk \
--client-details testType=pr,link=https://path/to/pull-request
[null,null,["Última actualización: 2025-08-16 (UTC)"],[],[],null,["\u003cbr /\u003e\n\n2nd gen 1st gen \n\nTrigger a function on TestMatrix completion\n\nCreate a new function that triggers when a TestMatrix completes with the event handler\n`functions.testLab.testMatrix().onComplete()`: \n\n exports.sendEmailNotification = functions.testLab.testMatrix().onComplete((testMatrix) =\u003e {\n // ...\n });\n\nHandle test states and outcomes\n\nEach execution of your function is passed a [`TestMatrix`](/docs/reference/functions/firebase-functions.testlab.testmatrix)\nwhich includes the final state of the matrix and details to help understand problems. \n\n exports.handleTestMatrixCompletion = functions.testLab.testMatrix().onComplete(testMatrix =\u003e {\n const matrixId = testMatrix.testMatrixId;\n switch (testMatrix.state) {\n case 'FINISHED':\n console.log(`TestMatrix ${matrixId} finished with outcome: ${testMatrix.outcomeSummary}`);\n break;\n case 'INVALID':\n console.log(`TestMatrix ${matrixId} was marked as invalid: ${testMatrix.invalidMatrixDetails}`);\n break;\n default:\n console.log(`TestMatrix ${matrixId} completed with state ${testMatrix.state}`);\n }\n return null;\n });\n\nAccess client details\n\nTest matrices may be created from different sources or workflows. It is therefore often desirable to\ncreate functions that perform different actions based on the source or other important context of\nthe test. To help with this, `gcloud` allows you to pass arbitrary information when starting a test\nthat can be accessed later in your function. For example: \n\n gcloud beta firebase test android run \\\n --app=path/to/app.apk \\\n --client-details testType=pr,link=https://path/to/pull-request\n\nExample function: \n\n exports.notifyOnPullRequestFailure = functions.testLab.testMatrix().onComplete(testMatrix =\u003e {\n if (testMatrix.clientInfo.details['testType'] != 'pr') {\n // Not a pull request\n return null;\n }\n\n if (testMatrix.state == 'FINISHED' && testMatrix.outcomeSummary == 'SUCCESS') {\n // No failure\n return null;\n }\n\n const link = testMatrix.clientInfo.details['link'];\n let message = `Test Lab validation for pull request ${link} failed. `;\n\n if (!!testMatrix.resultStorage.resultsUrl) {\n message += `Test results available at ${testMatrix.resultStorage.resultsUrl}. `;\n }\n\n // Send notification here ...\n });"]]