Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

236
Views
¿Cómo consultar Firestore desde un script k6?

Estamos tratando de consultar Firestore a través de un script k6 en una colección.
Para integrar la biblioteca de Firestore, seguimos esta guía en el sitio web de k6:
https://k6.io/docs/using-k6/modules/#setting-up-the-bundler

Cuando ejecutamos nuestro script, obtenemos este extraño error, que no podemos encontrar en la documentación de Firestore:

@firebase/firestore: Firestore (8.1.2): AsyncQueue Inicialización de la consulta 'Query(target=Target(my_collection_here, orderBy: [timestamp (asc), name (asc)]); limitType=F)' falló: TypeError: Value no es un objeto: indefinido

El guion es este:

 import 'core-js/stable'; import 'regenerator-runtime/runtime'; import firebase from 'firebase/app'; import 'firebase/firestore'; import { sleep } from 'k6'; import behavior from './tests/behaviors/index.js'; import scenariosAndStages from './tests/options/index.js'; const firebaseConfig = { apiKey: ***, authDomain: ***, projectId: ***, storageBucket: ***, messagingSenderId: ***, appId: ***, }; firebase.initializeApp(firebaseConfig); const db = firebase.firestore(); const conf = { multiply: __ENV.MULTIPLY || 1, }; export const options = { ext: { loadimpact: { name: __ENV.NAME, projectID: __ENV.PROJECT_ID, distribution: { 'amazon:us:ashburn': { loadZone: 'amazon:us:ashburn', percent: 100 }, }, }, }, discardResponseBodies: true, scenarios: __ENV.SCENARIOS ? { [__ENV.SCENARIOS]: scenariosAndStages.scenarios[__ENV.SCENARIOS] } : undefined, stages: scenariosAndStages.stages[__ENV.STAGES], }; export default () => { db .collection('my_collection_here') .orderBy('timestamp') .get() .then(console.log); sleep(10); behavior.myBehavior('application load test one call', conf.multiply); };

¿Qué estamos haciendo mal?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Después de una pequeña investigación, me di cuenta de que Firestore JS SDK requiere Node.js para funcionar, lo que lo hace incompatible con k6 según la documentación de k6 .

Recomendaría el emulador de Firebase para pruebas unitarias . Si uno prefiere simular ciertas funciones con fines de prueba, recomendaría usar Jest en su lugar, como se muestra aquí

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!