diff --git a/__tests__/integration/main.tsx b/__tests__/integration/main.tsx
index 7b769710..8baeb31d 100644
--- a/__tests__/integration/main.tsx
+++ b/__tests__/integration/main.tsx
@@ -41,20 +41,9 @@ const View: React.FC = () => {
return renderers[renderer];
}, [renderer]);
- const destroyShapeRecursive = (shape?: DisplayObject) => {
- if (!shape) return;
- if (shape.childNodes.length > 0) {
- for (let index = shape.childNodes.length - 1; index > 0; index--) {
- const child = shape.childNodes[index] as DisplayObject;
- destroyShapeRecursive(child);
- }
- }
- shape.destroy();
- };
-
const renderCase = (name: string) => {
if (!canvasRef.current || !casesName.includes(name)) return;
- destroyShapeRecursive(nodeRef.current);
+ nodeRef.current?.destroy();
const node = cases[name]();
nodeRef.current = node;
const title = cases[name].tags || [name];
diff --git a/__tests__/integration/snapshot.spec.ts b/__tests__/integration/snapshot.spec.ts
index cbe8eef9..2bdb85e3 100644
--- a/__tests__/integration/snapshot.spec.ts
+++ b/__tests__/integration/snapshot.spec.ts
@@ -1,5 +1,6 @@
+/* eslint-disable no-restricted-syntax */
import * as fs from 'fs';
-import { Canvas } from '@antv/g';
+import { Canvas, resetEntityCounter } from '@antv/g';
import { format } from 'prettier';
import xmlserializer from 'xmlserializer';
import * as tests from './components';
@@ -17,23 +18,28 @@ describe('integration', () => {
const finalTests = onlyTests.length === 0 ? tests : Object.fromEntries(onlyTests);
+ if (!fs.existsSync(`${__dirname}/snapshots`)) {
+ fs.mkdirSync(`${__dirname}/snapshots`);
+ }
+
for (const [name, target] of Object.entries(finalTests)) {
// @ts-ignore
if (!target.skip) {
it(`[Canvas]: ${name}`, async () => {
+ resetEntityCounter();
let canvas: Canvas | undefined;
let actual: string;
try {
const actualPath = `${__dirname}/snapshots/${name}-actual.svg`;
const expectedPath = `${__dirname}/snapshots/${name}.svg`;
- const options = await target();
+ const options = target();
// @ts-ignore
const wait = target.wait;
canvas = await renderCanvas(options, wait);
const container = canvas.getConfig().container as HTMLElement;
const dom = container.querySelector('svg');
- actual = await format(xmlserializer.serializeToString(dom as any), {
+ actual = format(xmlserializer.serializeToString(dom as any), {
parser: 'babel',
});
@@ -46,7 +52,7 @@ describe('integration', () => {
throw new Error(`Please generate golden image for ${name}`);
}
console.warn(`! generate ${name}`);
- await fs.writeFileSync(expectedPath, actual);
+ fs.writeFileSync(expectedPath, actual);
} else {
const expected = fs.readFileSync(expectedPath, {
encoding: 'utf8',
diff --git a/__tests__/integration/snapshots/AxisAnimationDisable.svg b/__tests__/integration/snapshots/AxisAnimationDisable.svg
index 5e1f779b..4003bb3d 100644
--- a/__tests__/integration/snapshots/AxisAnimationDisable.svg
+++ b/__tests__/integration/snapshots/AxisAnimationDisable.svg
@@ -8,14 +8,14 @@
-
-
-
-
-
+
+
+
+
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
-
-
-
+
+
+
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
-
-
-
+
+
+
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
-
-
-
+
+
+
+
-
-
+
+
-
+
-
+
-
+
-
+
-
-
-
-
-
-
+
+
+
+
+
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
-
-
-
+
+
+
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
-
-
-
+
+
+
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
-
-
-
+
+
+
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
-
-
-
+
+
+
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
-
-
-
+
+
+
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
-
-
-
+
+
+
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
-
-
-
+
+
+