Dolly zoom has often been used as evidence to show that "lens compression depends on subject distance not on focal length".
That argument is flawed because dolly zoom changes the subject distance in proportion to the change in focal length. Both subject distance and focal length are being changed together. Both contribute to the spectacular effect seen with dolly zoom.
If you want to see lens compression alone, then do a stationary zoom where the subject distance remains the same.
For example, suppose the wide end of the zoom gives a natural look with your subject 100m away and the background 200m away, then if you zoom right in with a 10x zoom that will magnify the image ten times. Your subject will then appear to be 10m away and the background will appear to be 20m away. The distance between subject and background appears to shrink from 100m to 10m.
Remember that this appearance of depth in the image is an optical illusion. You are really looking at a 2-D image. Your brain imagines the scene in 3-D.
Magnifying your view is what causes the illusion of depth to change.
You can magnify your view by enlarging the image or moving closer to it or using a longer focal length to take the shot. If you are looking at a scene directly, you can magnify your view of that scene by looking through a telescope or binoculars. All have a similar effect on depth perception. The camera position and subject distance are irrelevant.