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

173
Views
I'm getting error when unit testing a method that calls empty() on an object

Test is erroring with

dataLayerHelper
generateProductLinesDataLayer
extends the datalayer:
ReferenceError: empty is not defined
at Object.generateProductLinesDataLayer (cartridges\gtm\int_gtm_sfra_custom\cartridge\scripts\gtm\dataLayerHelper.js:42:9)
at Context.<anonymous> (cartridges\test\unit\gtm\int_gtm_sfra_custom\scripts\dataLayerHelper.js:59:42)
at processImmediate (internal/timers.js:464:21)
at process.callbackTrampoline (internal/async_hooks.js:131:17)

Here:

if (!empty(pli.product) && pli.product.isVariant()) {
    pid = pli.product.masterProduct.ID;
    variant = pli.productID;
}

Why would I get an error when testing a method that uses a built in empty() method that doesn't require any other reference?

Test:

describe("generateProductLinesDataLayer", function () {
        it.only(" extends the datalayer", function () {
            var result = dataLayerHelper.generateProductLinesDataLayer(productLineItems);
            assert.deepEqual(result, []);
        });
    });
function generateProductLinesDataLayer(productLineItems) {
......
        if (!empty(pli.product) && pli.product.isVariant()) {
            pid = pli.product.masterProduct.ID;
            variant = pli.productID;
        }
......
}

about 4 years ago · Juan Pablo Isaza
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!