Jest did not exit, but no asynchronous code? Should I mock?

I’m creating a text based adventure game to practice testing, I’m using Jest and I have really enjoyed it so far.

I am now testing a function that decreases an objects value by 1 (player.health), when I created the test it does passed successfully and the health does decrease but I get…

Jest did not exit one second after the test run has completed.

This usually means that there are asynchronous operations that weren’t stopped in your tests. Consider running Jest with --detectOpenHandles to troubleshoot this issue.

I’m not awaiting any promises, so not sure why I’m getting this message, I tried to run –detectOpenHandles but this doesn’t seem to print anything. Why am I getting this message?

This may be unrelated but should I be mocking the healthDecrease function? It was my understanding that because I have control I do not need to mock.

index.js – where the player object is and order of the game will be executed

const { name } = require('./functions/inq')

let player = {
    name: "",
    weapon: "",
    health: 10
}


const start = async () => {
    console.log('what name?')
    player.name = await name()
    console.log('hello', player.name)
}
start()

module.exports = {
    player
}

functions.js – where the basic functions for the game are stored

const { player } = require('../index')



const healthDecrease = () => {
    return player.health--
}

module.exports = {
    healthDecrease
}

functions.test.js – test file

const { healthDecrease } = require('../functions/functions')
const { player } = require('../index')

describe('decrease user health', () => {
    test('health decreases by 1', () => {
        healthDecrease()
        expect(player.health).toBe(10) //will fail
    })
    test('health decreases by 2', () => {
        healthDecrease()
        healthDecrease()
        expect(player.health).toBe(10) //will fail
    })
})