Skip to content

🎥 Make videos programmatically with React

add test

Jonny Burger6055fbbadc50
diff --git a/packages/web-renderer/src/test/Root.tsx b/packages/web-renderer/src/test/Root.tsx
index 5383965f1b..1ab59a3dee 100644
--- a/packages/web-renderer/src/test/Root.tsx
+++ b/packages/web-renderer/src/test/Root.tsx
@@ -42,6 +42,7 @@ import {rotatedCanvas} from './fixtures/rotated-canvas';
import {scaledTranslatedSvg} from './fixtures/scaled-translated-svg';
import {selfTransformOrigin} from './fixtures/self-transform-origin';
import {simpleRotatedSvg} from './fixtures/simple-rotated-svg';
+import {svgExplicitDimensions} from './fixtures/svg-explicit-dimensions';
import {letterSpacing} from './fixtures/text/letter-spacing';
import {paragraphs} from './fixtures/text/paragraphs';
import {textFixture} from './fixtures/text/text';
@@ -79,6 +80,7 @@ export const Root: React.FC = () => {
<Composition {...hugeImageTransform} />
<Composition {...nestedTranslateScale} />
<Composition {...scaledTranslatedSvg} />
+ <Composition {...svgExplicitDimensions} />
<Composition {...flexPositionedScaled} />
<Composition {...displayNone} />
<Folder name="Opacity">
diff --git a/packages/web-renderer/src/test/fixtures/svg-explicit-dimensions.tsx b/packages/web-renderer/src/test/fixtures/svg-explicit-dimensions.tsx
new file mode 100644
index 0000000000..6ad8b83ee9
--- /dev/null
+++ b/packages/web-renderer/src/test/fixtures/svg-explicit-dimensions.tsx
@@ -0,0 +1,49 @@
+import React from 'react';
+import {AbsoluteFill} from 'remotion';
+
+/**
+ * Reproduces issue #6186: SVG with explicit width/height properties
+ * and viewBox renders incorrectly - the SVG appears smaller than intended,
+ * constrained to parent container size instead of respecting its own dimensions.
+ *
+ * The SVG has width={1080} height={1080} as props (not just styles),
+ * but is inside a smaller container (256×284px). The SVG should render
+ * at its specified dimensions and overflow the container.
+ */
+const Component: React.FC = () => {
+ return (
+ <AbsoluteFill
+ style={{
+ justifyContent: 'center',
+ alignItems: 'center',
+ backgroundColor: '#f0f0f0',
+ }}
+ >
+ <div
+ style={{
+ width: 256,
+ height: 284,
+ backgroundColor: '#e0e0e0',
+ display: 'flex',
+ justifyContent: 'center',
+ alignItems: 'center',
+ }}
+ >
+ <svg viewBox="0 0 1080 1080" fill="none">
+ <rect x="0" y="0" width="1080" height="1080" fill="#3498db" />
+ <circle cx="540" cy="540" r="400" fill="#e74c3c" />
+ <rect x="340" y="340" width="400" height="400" fill="#2ecc71" />
+ </svg>
+ </div>
+ </AbsoluteFill>
+ );
+};
+
+export const svgExplicitDimensions = {
+ component: Component,
+ id: 'svg-explicit-dimensions',
+ width: 1080,
+ height: 1080,
+ fps: 30,
+ durationInFrames: 1,
+} as const;
diff --git a/packages/web-renderer/src/test/transforms.test.tsx b/packages/web-renderer/src/test/transforms.test.tsx
index 995e78d3f5..0219282e52 100644
--- a/packages/web-renderer/src/test/transforms.test.tsx
+++ b/packages/web-renderer/src/test/transforms.test.tsx
@@ -18,6 +18,7 @@ import {orthographic} from './fixtures/transforms/orthographic';
import {withMargin} from './fixtures/transforms/with-margin';
import {withNegativeMargin} from './fixtures/transforms/with-negative-margin';
import {unwrapped} from './fixtures/unwrapped';
+import {svgExplicitDimensions} from './fixtures/svg-explicit-dimensions';
import {testImage} from './utils';
test('should be able to deal with a simple transform directly on the element', async () => {
@@ -245,3 +246,17 @@ test('Should render with negative margin', async () => {
await testImage({blob, testId: 'with-negative-margin'});
});
+
+test('SVG with explicit width/height props should render at specified size (issue #6186)', async () => {
+ await page.viewport(1080, 1080);
+
+ const {blob} = await renderStillOnWeb({
+ licenseKey: 'free-license',
+ composition: svgExplicitDimensions,
+ frame: 0,
+ inputProps: {},
+ imageFormat: 'png',
+ });
+
+ await testImage({blob, testId: 'svg-explicit-dimensions'});
+});