@quake2ts/test-utils 0.0.853 → 0.0.855
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +16 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -1
- package/package.json +9 -9
- package/src/visual/animation-snapshots.ts +25 -4
package/dist/index.cjs
CHANGED
|
@@ -4888,6 +4888,22 @@ async function expectAnimationSnapshot(renderAndCaptureFrame, options) {
|
|
|
4888
4888
|
shouldUpdateBaseline = true;
|
|
4889
4889
|
}
|
|
4890
4890
|
}
|
|
4891
|
+
if (actualFrames.length > 1) {
|
|
4892
|
+
const firstFrame = actualFrames[0];
|
|
4893
|
+
const lastFrame = actualFrames[actualFrames.length - 1];
|
|
4894
|
+
let differentPixels = 0;
|
|
4895
|
+
for (let i = 0; i < firstFrame.length; i += 4) {
|
|
4896
|
+
if (firstFrame[i] !== lastFrame[i] || firstFrame[i + 1] !== lastFrame[i + 1] || firstFrame[i + 2] !== lastFrame[i + 2]) {
|
|
4897
|
+
differentPixels++;
|
|
4898
|
+
}
|
|
4899
|
+
}
|
|
4900
|
+
const percentDiff = differentPixels / (width * height) * 100;
|
|
4901
|
+
if (percentDiff < 0.1) {
|
|
4902
|
+
console.warn(`WARNING: Animation '${name}' has minimal changes (${percentDiff.toFixed(2)}% pixels different). First and last frames are nearly identical - animation may not be working!`);
|
|
4903
|
+
} else {
|
|
4904
|
+
console.log(`Animation '${name}': ${percentDiff.toFixed(2)}% of pixels changed from first to last frame`);
|
|
4905
|
+
}
|
|
4906
|
+
}
|
|
4891
4907
|
if (shouldUpdateBaseline) {
|
|
4892
4908
|
console.log(`Creating/Updating baseline for ${name} at ${baselinePath}`);
|
|
4893
4909
|
await saveAPNG(baselinePath, actualFrames, width, height, delayMs);
|