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

151
Views
Why Object.assign does not work properly in Jest?

somefile.unit.test.js //jest unit test file

import pageData from '../__mocks__/somefile.mock.json';
...
describe('My component', () => {
  it('Test 1', async () => {
    const page = Object.assign({}, pageData);
    page.someprop = 'baboon';
  });
  it('Test 2', async () => {
    const page = Object.assign({}, pageData);
    console.log(page.someprop); //baboon
  });
});

I want imported objects will be immutable. Trying to clone it with "Object.assign", but for some reason, pageData does not clone and by changing "page" i do change "pageData" at the same time.

Why Object.assign does not work in Jest? ( I've tried jest.unmock('object-assign') )

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!