My code expected value shows different than npm expected value

I tried writing the code in separate file in VS code. At my other file, when I tried to call the function findTheOldest(people) in the browser, it displayed the name Ray. This is expected value of the npm test. So I copied all the previous code to my real test code file. As I ran the npm test on this file, the expected value shown is Carly ? What ?? Why is the value displayed different now ? As far as I concern, everything in the code is the same but now it shows different expected value ? Is this right ?

const people = [
  {
    name: "Carly",
    yearOfBirth: 1942,
    yearOfDeath: 1970,
  },
  {
    name: "Ray",
    yearOfBirth: 1962,
    yearOfDeath: 2011,
  },
  {
    name: "Jane",
    yearOfBirth: 1912,
    yearOfDeath: 1941,
  },
]

let oldestPeople = people.sort(function(a,b) {
  const aFirstPerson = a.yearOfDeath - a.yearOfBirth;
  const bSecondPerson = b.yearOfDeath - b.yearOfBirth;

  if (aFirstPerson > bSecondPerson) {
    return -1;
  } else {
    return 1;
  }
})

const findTheOldest = function(people) {
  return people[0];
}

findTheOldest(people);

// Do not edit below this line
module.exports = findTheOldest;

———Below is the NPM test code ———-

const findTheOldest = require('./findTheOldest')

describe('findTheOldest', () => {
  test('finds the oldest person!', () => {
    const people = [
      {
        name: "Carly",
        yearOfBirth: 1942,
        yearOfDeath: 1970,
      },
      {
        name: "Ray",
        yearOfBirth: 1962,
        yearOfDeath: 2011,
      },
      {
        name: "Jane",
        yearOfBirth: 1912,
        yearOfDeath: 1941,
      },
    ]
    expect(findTheOldest(people).name).toBe('Ray');
  });