Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uncaught AssertionError: .empty was passed non-string primitive 1

Tags:

mocha.js

chai

When I give this statement as below, an "Uncaught AssertionError: .empty was passed non-string primitive 1" is thrown expect(res.body.invoiceDetails.lineItems[0].invLineId).to.be.a('Number').and.not.to.be.empty;

like image 796
Bhuvana Avatar asked Sep 29 '26 09:09

Bhuvana


2 Answers

Try not.to.be.null instead of not.to.be.empty

like image 59
Oksana Kioresku Avatar answered Oct 02 '26 00:10

Oksana Kioresku


According to the chai documentation, .empty checks weather an array is empty or if a string has a length of 0:

.empty

When the target is a string or array, .empty asserts that the target’s length property is strictly (===) equal to 0.

It looks like you are expecting 'res.body.invoiceDetails.lineItems[0].invLineId' to be a number so the assertion is failing.

like image 24
goteamtim Avatar answered Oct 01 '26 22:10

goteamtim