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

233
Views
How to query Firestore from a k6 script?

We're trying to query Firestore via a k6 script on a collection.
In order to integrate the Firestore library we followed this guide on k6 website:
https://k6.io/docs/using-k6/modules/#setting-up-the-bundler

When we run our script we get this weird error, that we can't find on Firestore documentation:

@firebase/firestore: Firestore (8.1.2): AsyncQueue Initialization of query 'Query(target=Target(my_collection_here, orderBy: [timestamp (asc), name (asc)]); limitType=F)' failed: TypeError: Value is not an object: undefined

The script is this:

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);
};

What are we doing wrong?

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

0

After some light research I've come to realize that the Firestore JS SDK requires Node.js in order to function, making it incompatible with k6 according to k6's documentation.

I would recommend the Firebase emulator for unit testing. If one would prefer to mock certain functions for testing purposes, I would recommend using Jest instead, as shown here

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!