🎥 Make videos programmatically with React
composition length must be an integer
Jonny Burger86474e20fb32
diff --git a/packages/core/src/Composition.tsx b/packages/core/src/Composition.tsxindex c8c31952ec..a8a442bcac 100644--- a/packages/core/src/Composition.tsx+++ b/packages/core/src/Composition.tsx@@ -91,6 +91,11 @@ export const Composition = <T,>({`The "durationInFrames" of a composition must be positive, but got ${durationInFrames}.`);}+ if (durationInFrames % 1 !== 0) {+ throw new TypeError(+ `The "durationInFrames" of a composition must be an integer, but got ${durationInFrames}.`+ );+ }if (typeof fps !== 'number') {throw new Error(`The "fps" of a composition must be a number, but you passed a ${typeof fps}`diff --git a/packages/core/src/test/composition-validation.test.tsx b/packages/core/src/test/composition-validation.test.tsxindex 2aa5410300..fbcd2ba36d 100644--- a/packages/core/src/test/composition-validation.test.tsx+++ b/packages/core/src/test/composition-validation.test.tsx@@ -229,6 +229,24 @@ test('It should throw if durationInFrames=0 of a composition is boundary off-poi/The "durationInFrames" of a composition must be positive, but got 0./);});+test('It should throw if durationInFrames of a composition is not an integer', () => {+ expectToThrow(+ () =>+ render(+ <RemotionRoot>+ <Composition+ lazyComponent={() => Promise.resolve({default: AnyComp})}+ durationInFrames={0.11}+ fps={30}+ height={100}+ width={100}+ id="id"+ />+ </RemotionRoot>+ ),+ /The "durationInFrames" of a composition must be an integer, but got 0.11./+ );+});test('It should not throw if durationInFrames=1 of a composition is boundary on-point', () => {expect(() =>render(