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

324
Views
TypeError: Cannot read property 'uuid' of undefined faker-js faker

I am trying to use faker-js package, but I unexpectedly get a TypeError: Cannot read property 'uuid' of undefined for my variable businessId which try to use faker.datatype.uuid()

It usually happen when I forget to install faker-js, but that's not the case here, and I check that I imported this package. Therefore I am clueless on what I am doing wrong here.

// eslint-disable-next-line import/order
const { initConfig } = require('../../../config');

initConfig();

const sinon = require('sinon');
const faker = require('@faker-js/faker');
const { retryAsyncCall } = require('../../../src/common/helpers/retry-async');
const { createFacebookAdVideoFromUrl } = require('../../../src/common/controllers/facebook/api');

function createPayloadDataBuilder(payload = {}) {
  const template = {
    accountId: faker.datatype.uuid(),
    publicLink: faker.internet.url(),
    videoName: faker.lorem.word(),
    facebookToken: undefined,
    params: null,
    businessId: faker.datatype.uuid(),
  };
  return { ...payload, ...template };
}

describe('Facebook Gateway', () => {
  describe('createFacebookAdVideoFromUrl', () => {
    describe('Given businessId', () => {
      it.only("should create the video calling business's Facebook ids", async () => {
        const businessId = faker.datatype.uuid();
        console.log(faker, businessId);
        const createFacebookAdVideoPayload = createPayloadDataBuilder({
          businessId,
        });

        await createFacebookAdVideoFromUrl(...createFacebookAdVideoPayload);

        // sinon.assert.called(retryAsyncCall);
      });
    });
  });
});
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Found it! I need to destructure the import:

const { faker } = require('@faker-js/faker');

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!