I want to create a mock div that has display: none for testing purposes. However, setting the display in the test and then calling getComputedStyle shows no change in the style, i.e.
const parent = document.createElement('div');
const middle = document.createElement('div');
// If you check in the dom, the middle div clearly has display: none as
// part of its style
middle.style.display = 'none';
parent.appendChild(middle);
// Supposed to be 'none', but is actually ''
console.log(getComputedStyle(middle).display);
It seems like other people have said that getComputedStyle forces a redraw of the screen, but it seems like it is not getting the updated display of middle. How can I force getComputedStyle to update to the display value?