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

459
Views
TypeError: expect.any is not a function

Im using create-react-app and Im trying to write a test in jest for my action creator. One of the fields that the action adds is a random ID so I want to use expect.any(String) so that the test will pass. However I'm getting TypeError: expect.any is not a function

Here is my test:

describe('actions', () => {

it('should create an action to add a ticket', () => {
 const payload = {
     summary: 'A summary',
     description: 'A description',
     status:'open',
     priority: 'minor',
  };

  const expected = {
    type: actions.ADD_TICKET,
    ticket: {
          ...payload,
          id: expect.any(String),
      },
  };

  const actual = addTicket(payload);

  expect(actual).toEqual(expected)
 })
})
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

expect.any was added in Jest 18 which wasnt shipping with this version of create-react-app. The version they just pushed now supports it

over 4 years ago · Santiago Trujillo 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!