Skip to content

🎥 Make videos programmatically with React

fix console.log spam in core test

Jonny Burger6c4a480e8feb
diff --git a/packages/core/src/test/series.test.tsx b/packages/core/src/test/series.test.tsx
index 67a6a74618..750136f979 100644
--- a/packages/core/src/test/series.test.tsx
+++ b/packages/core/src/test/series.test.tsx
@@ -2,8 +2,8 @@
* @vitest-environment jsdom
*/
/* eslint-disable react/jsx-no-constructed-context-values */
-import {render} from '@testing-library/react';
import React from 'react';
+import {renderToString} from 'react-dom/server';
import {expect, test} from 'vitest';
import {CanUseRemotionHooksProvider} from '../CanUseRemotionHooks.js';
import {Series} from '../series';
@@ -27,7 +27,7 @@ const Third = () => {
};
const renderForFrame = (frame: number, markup: React.ReactNode) => {
- return render(
+ return renderToString(
<CanUseRemotionHooksProvider>
<TimelineContext.Provider
value={{
@@ -51,7 +51,7 @@ const renderForFrame = (frame: number, markup: React.ReactNode) => {
};
test('Basic series test', () => {
- const {queryByText} = renderForFrame(
+ const outerHTML = renderForFrame(
10,
<WrapSequenceContext>
<Series>
@@ -67,11 +67,13 @@ test('Basic series test', () => {
</Series>
</WrapSequenceContext>
);
- expect(queryByText(/^third\s0$/)).not.toBe(null);
+ expect(outerHTML).toBe(
+ '<div style="position:absolute;top:0;left:0;right:0;bottom:0;width:100%;height:100%;display:flex"><div>third 0</div></div>'
+ );
});
test('Should support fragments', () => {
- const {container} = renderForFrame(
+ const outerHtml = renderForFrame(
10,
<WrapSequenceContext>
<Series>
@@ -90,11 +92,14 @@ test('Should support fragments', () => {
</WrapSequenceContext>
);
- expect(container.outerHTML).not.toBe(null);
+ expect(outerHtml).not.toBe(
+ '<div style="position:absolute;top:0;left:0;right:0;bottom:0;width:100%;height:100%;display:flex"><div>second 1</div></div>'
+ );
});
test('Should not allow foreign elements', () => {
expect(() => {
- render(
+ renderForFrame(
+ 0,
<WrapSequenceContext>
<Series>
<First />
@@ -104,7 +109,7 @@ test('Should not allow foreign elements', () => {
}).toThrow(/only accepts a/);
});
test('Should allow layout prop', () => {
- const {container} = renderForFrame(
+ const outerHTML = renderForFrame(
0,
<WrapSequenceContext>
<Series>
@@ -114,11 +119,11 @@ test('Should allow layout prop', () => {
</Series>
</WrapSequenceContext>
);
- expect(container.outerHTML).toBe(
- '<div><div style="position: absolute; top: 0px; left: 0px; right: 0px; bottom: 0px; width: 100%; height: 100%; display: flex;"><div>first 0</div></div></div>'
+ expect(outerHTML).toBe(
+ '<div style="position:absolute;top:0;left:0;right:0;bottom:0;width:100%;height:100%;display:flex"><div>first 0</div></div>'
);
- const {container: withoutLayoutContainer} = renderForFrame(
+ const outerHTML2 = renderForFrame(
0,
<WrapSequenceContext>
<Series>
@@ -128,12 +133,10 @@ test('Should allow layout prop', () => {
</Series>
</WrapSequenceContext>
);
- expect(withoutLayoutContainer.outerHTML).toBe(
- '<div><div>first 0</div></div>'
- );
+ expect(outerHTML2).toBe('<div>first 0</div>');
});
test('Should render nothing after the end', () => {
- const {container} = renderForFrame(
+ const outerHTML = renderForFrame(
10,
<WrapSequenceContext>
<Series>
@@ -143,7 +146,7 @@ test('Should render nothing after the end', () => {
</Series>
</WrapSequenceContext>
);
- expect(container.outerHTML).toBe('<div></div>');
+ expect(outerHTML).toBe('');
});
test('Should throw if invalid or no duration provided', () => {
expect(() => {
@@ -174,20 +177,23 @@ test('Should throw if invalid or no duration provided', () => {
);
});
test('Should allow whitespace', () => {
- const {queryByText} = renderForFrame(
+ const outerHtml = renderForFrame(
11,
<WrapSequenceContext>
<Series>
<Series.Sequence durationInFrames={10}>
<First />
- </Series.Sequence>
+ </Series.Sequence>{' '}
<Series.Sequence durationInFrames={10}>
<Second />
</Series.Sequence>
</Series>
</WrapSequenceContext>
);
- expect(queryByText(/^second\s1$/g)).not.toBe(null);
+
+ expect(outerHtml).toBe(
+ '<div style="position:absolute;top:0;left:0;right:0;bottom:0;width:100%;height:100%;display:flex"><div>second 1</div></div>'
+ );
});
test('Handle empty Series.Sequence', () => {
expect(() =>
@@ -206,7 +212,7 @@ test('Handle empty Series.Sequence', () => {
});
test('Should allow negative overlap prop', () => {
- const {container} = renderForFrame(
+ const outerHTML = renderForFrame(
4,
<WrapSequenceContext>
<Series>
@@ -219,13 +225,11 @@ test('Should allow negative overlap prop', () => {
</Series>
</WrapSequenceContext>
);
- expect(container.outerHTML).toBe(
- '<div><div>first 4</div><div>second 0</div></div>'
- );
+ expect(outerHTML).toBe('<div>first 4</div><div>second 0</div>');
});
test('Should allow positive overlap prop', () => {
- const {container} = renderForFrame(
+ const outerHTML = renderForFrame(
5,
<WrapSequenceContext>
<Series>
@@ -238,7 +242,7 @@ test('Should allow positive overlap prop', () => {
</Series>
</WrapSequenceContext>
);
- expect(container.outerHTML).toBe('<div></div>');
+ expect(outerHTML).toBe('');
});
test('Should disallow NaN as offset prop', () => {
@@ -287,7 +291,7 @@ test('Should disallow non-integer numbers as offset prop', () => {
});
test('Should cascade negative offset props', () => {
- const {container} = renderForFrame(
+ const outerHTML = renderForFrame(
9,
<WrapSequenceContext>
<Series>
@@ -303,11 +307,11 @@ test('Should cascade negative offset props', () => {
</Series>
</WrapSequenceContext>
);
- expect(container.outerHTML).toBe('<div><div>third 0</div></div>');
+ expect(outerHTML).toBe('<div>third 0</div>');
});
test('Should cascade positive offset props', () => {
- const {container} = renderForFrame(
+ const outerHTML = renderForFrame(
11,
<WrapSequenceContext>
<Series>
@@ -323,11 +327,11 @@ test('Should cascade positive offset props', () => {
</Series>
</WrapSequenceContext>
);
- expect(container.outerHTML).toBe('<div><div>third 0</div></div>');
+ expect(outerHTML).toBe('<div>third 0</div>');
});
test('Allow durationInFrames as Infinity for last Series.Sequence', () => {
- const {container} = renderForFrame(
+ const outerHTML = renderForFrame(
10,
<WrapSequenceContext>
<Series>
@@ -343,8 +347,8 @@ test('Allow durationInFrames as Infinity for last Series.Sequence', () => {
</Series>
</WrapSequenceContext>
);
- expect(container.outerHTML).toBe(
- '<div><div style="position: absolute; top: 0px; left: 0px; right: 0px; bottom: 0px; width: 100%; height: 100%; display: flex;"><div>third 0</div></div></div>'
+ expect(outerHTML).toBe(
+ '<div style="position:absolute;top:0;left:0;right:0;bottom:0;width:100%;height:100%;display:flex"><div>third 0</div></div>'
);
});
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 10523752ed..d6429ce975 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -216,7 +216,7 @@ importers:
packages/core:
specifiers:
'@jonny/eslint-config': 3.0.266
- '@testing-library/react': 13.3.0
+ '@testing-library/react': 14.0.0
'@types/node': ^16.7.5
'@types/react': 18.0.26
'@types/react-dom': 18.0.10
@@ -224,18 +224,17 @@ importers:
'@vitejs/plugin-react': ^2.0.0
eslint: 8.25.0
eslint-plugin-require-extensions: ^0.1.2
- jsdom: 20.0.1
+ jsdom: 21.1.0
prettier: ^2.7.1
prettier-plugin-organize-imports: ^2.3.4
react: ^18.0.0
react-dom: ^18.0.0
- react-test-renderer: ^18.0.0
rimraf: ^3.0.2
typescript: ^4.7.0
vitest: 0.24.3
devDependencies:
'@jonny/eslint-config': 3.0.266_t54va6jeo5lf3vtqih5uiyrm5e
- '@testing-library/react': 13.3.0_zpnidt7m3osuk7shl3s4oenomq
+ '@testing-library/react': 14.0.0_zpnidt7m3osuk7shl3s4oenomq
'@types/node': 16.10.2
'@types/react': 18.0.26
'@types/react-dom': 18.0.10
@@ -243,15 +242,14 @@ importers:
'@vitejs/plugin-react': [email protected]
eslint: 8.25.0
eslint-plugin-require-extensions: [email protected]
- jsdom: 20.0.1
+ jsdom: 21.1.0
prettier: 2.7.1
prettier-plugin-organize-imports: 2.3.4_j2odc4yr77iddtreafyicbq5hi
react: 18.0.0
react-dom: [email protected]
- react-test-renderer: [email protected]
rimraf: 3.0.2
typescript: 4.7.2
packages/create-video:
specifiers:
@@ -3178,7 +3176,7 @@ packages:
resolution: {integrity: sha512-u7stbOuYjaPezCuLj29hNW1v64M2Md2qupEKP1fHc7WdOA3DgLh37suiSrZYY7haUB7iBeQZ9P1uiRF359do3g==}
engines: {node: '>=6.9.0'}
dependencies:
- '@babel/helper-validator-identifier': 7.18.6
+ '@babel/helper-validator-identifier': 7.19.1
chalk: 2.4.2
js-tokens: 4.0.0
@@ -8995,6 +8993,20 @@ packages:
pretty-format: 27.2.4
dev: true
+ /@testing-library/dom/9.0.0:
+ resolution: {integrity: sha512-+/TLgKNFsYUshOY/zXsQOk+PlFQK+eyJ9T13IDVNJEi+M+Un7xlJK+FZKkbGSnf0+7E1G6PlDhkSYQ/GFiruBQ==}
+ engines: {node: '>=14'}
+ dependencies:
+ '@babel/code-frame': 7.18.6
+ '@babel/runtime': 7.19.0
+ '@types/aria-query': 5.0.1
+ aria-query: 5.0.0
+ chalk: 4.1.2
+ dom-accessibility-api: 0.5.14
+ lz-string: 1.4.4
+ pretty-format: 27.2.4
+ dev: true
+
/@testing-library/react/13.1.1_zpnidt7m3osuk7shl3s4oenomq:
resolution: {integrity: sha512-8mirlAa0OKaUvnqnZF6MdAh2tReYA2KtWVw1PKvaF5EcCZqgK5pl8iF+3uW90JdG5Ua2c2c2E2wtLdaug3dsVg==}
engines: {node: '>=12'}
@@ -9037,6 +9049,20 @@ packages:
react-dom: [email protected]
dev: true
+ /@testing-library/react/14.0.0_zpnidt7m3osuk7shl3s4oenomq:
+ resolution: {integrity: sha512-S04gSNJbYE30TlIMLTzv6QCTzt9AqIF5y6s6SzVFILNcNvbV/jU96GeiTPillGQo+Ny64M/5PV7klNYYgv5Dfg==}
+ engines: {node: '>=14'}
+ peerDependencies:
+ react: ^18.0.0
+ react-dom: ^18.0.0
+ dependencies:
+ '@babel/runtime': 7.19.0
+ '@testing-library/dom': 9.0.0
+ '@types/react-dom': 18.0.10
+ react: 18.0.0
+ react-dom: [email protected]
+ dev: true
+
/@tootallnate/once/1.1.2:
resolution: {integrity: sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw==}
engines: {node: '>= 6'}
@@ -9076,6 +9102,10 @@ packages:
resolution: {integrity: sha512-HnYpAE1Y6kRyKM/XkEuiRQhTHvkzMBurTHnpFLYLBGPIylZNPs9jJcuOOYWxPLJCSEtmZT0Y8rHDokKN7rRTig==}
dev: true
+ /@types/aria-query/5.0.1:
+ resolution: {integrity: sha512-XTIieEY+gvJ39ChLcB4If5zHtPxt3Syj5rgZR+e1ctpmK8NjPf0zFqsz4JpLJT0xla9GFDKjy8Cpu331nrmE1Q==}
+ dev: true
+
/@types/babel__core/7.1.16:
resolution: {integrity: sha512-EAEHtisTMM+KaKwfWdC3oyllIqswlznXCIVCt7/oRNrh+DhgT4UEBNC/jlADNjvw7UnfbcdkGQcPVZ1xYiLcrQ==}
dependencies:
@@ -10167,7 +10197,7 @@ packages:
/acorn-globals/7.0.1:
resolution: {integrity: sha512-umOSDSDrfHbTNPuNpC2NSnnA3LUrqpevPb4T9jRx4MagXNS0rs+gwiTcAvqCRmsD6utzsrzNt+ebm00SNWiC3Q==}
dependencies:
- acorn: 8.8.0
+ acorn: 8.8.1
acorn-walk: 8.2.0
dev: true
@@ -16098,6 +16128,47 @@ packages:
- utf-8-validate
dev: true
+ /jsdom/21.1.0:
+ resolution: {integrity: sha512-m0lzlP7qOtthD918nenK3hdItSd2I+V3W9IrBcB36sqDwG+KnUs66IF5GY7laGWUnlM9vTsD0W1QwSEBYWWcJg==}
+ engines: {node: '>=14'}
+ peerDependencies:
+ canvas: ^2.5.0
+ peerDependenciesMeta:
+ canvas:
+ optional: true
+ dependencies:
+ abab: 2.0.6
+ acorn: 8.8.1
+ acorn-globals: 7.0.1
+ cssom: 0.5.0
+ cssstyle: 2.3.0
+ data-urls: 3.0.2
+ decimal.js: 10.4.2
+ domexception: 4.0.0
+ escodegen: 2.0.0
+ form-data: 4.0.0
+ html-encoding-sniffer: 3.0.0
+ http-proxy-agent: 5.0.0
+ https-proxy-agent: 5.0.1
+ is-potential-custom-element-name: 1.0.1
+ nwsapi: 2.2.2
+ parse5: 7.1.1
+ saxes: 6.0.0
+ symbol-tree: 3.2.4
+ tough-cookie: 4.1.2
+ w3c-xmlserializer: 4.0.0
+ webidl-conversions: 7.0.0
+ whatwg-encoding: 2.0.0
+ whatwg-mimetype: 3.0.0
+ whatwg-url: 11.0.0
+ ws: 8.12.1
+ xml-name-validator: 4.0.0
+ transitivePeerDependencies:
+ - bufferutil
+ - supports-color
+ - utf-8-validate
+ dev: true
+
/jsesc/0.5.0:
resolution: {integrity: sha512-uZz5UnB7u4T9LvwmFqXii7pZSouaRPorGs5who1Ip7VO0wxanFvBL7GkM6dTHlgX+jhBApRetaWpnDabOeTcnA==}
hasBin: true
@@ -20193,17 +20264,6 @@ packages:
react: 18.0.0
react-is: 18.0.0
- /react-test-renderer/[email protected]:
- resolution: {integrity: sha512-SyZTP/FSkwfiKOZuTZiISzsrC8A80KNlQ8PyyoGoOq+VzMAab6Em1POK/CiX3+XyXG6oiJa1C53zYDbdrJu9fw==}
- peerDependencies:
- react: ^18.0.0
- dependencies:
- react: 18.0.0
- react-is: 18.0.0
- react-shallow-renderer: [email protected]
- scheduler: 0.21.0
- dev: true
-
/react-textarea-autosize/8.3.3_mibu4szvw4ek6m273klteqcdre:
resolution: {integrity: sha512-2XlHXK2TDxS6vbQaoPbMOfQ8GK7+irc2fVK6QFIcC8GOnH3zI/v481n+j1L0WaPVvKxwesnY93fEfH++sus2rQ==}
engines: {node: '>=10'}
@@ -23722,6 +23782,48 @@ packages:
- terser
dev: true
+ resolution: {integrity: sha512-aM0auuPPgMSstWvr851hB74g/LKaKBzSxcG3da7ejfZbx08Y21JpZmbmDYrMTCGhVZKqTGwzcnLMwyfz2WzkhQ==}
+ engines: {node: '>=v14.16.0'}
+ hasBin: true
+ peerDependencies:
+ '@edge-runtime/vm': '*'
+ '@vitest/browser': '*'
+ '@vitest/ui': '*'
+ happy-dom: '*'
+ jsdom: '*'
+ peerDependenciesMeta:
+ '@edge-runtime/vm':
+ optional: true
+ '@vitest/browser':
+ optional: true
+ '@vitest/ui':
+ optional: true
+ happy-dom:
+ optional: true
+ jsdom:
+ optional: true
+ dependencies:
+ '@types/chai': 4.3.3
+ '@types/chai-subset': 1.3.3
+ '@types/node': 18.11.2
+ chai: 4.3.6
+ debug: 4.3.4
+ jsdom: 21.1.0
+ local-pkg: 0.4.2
+ strip-literal: 0.4.2
+ tinybench: 2.3.0
+ tinypool: 0.3.0
+ tinyspy: 1.0.2
+ vite: 3.0.0
+ transitivePeerDependencies:
+ - less
+ - sass
+ - stylus
+ - supports-color
+ - terser
+ dev: true
+
/vitest/0.27.2:
resolution: {integrity: sha512-y7tdsL2uaQy+KF18AlmNHZe29ukyFytlxrpSTwwmgLE2XHR/aPucJP9FLjWoqjgqFlXzRAjHlFJLU+HDyI/OsA==}
engines: {node: '>=v14.16.0'}
@@ -23846,6 +23948,13 @@ packages:
xml-name-validator: 4.0.0
dev: true
+ /w3c-xmlserializer/4.0.0:
+ resolution: {integrity: sha512-d+BFHzbiCx6zGfz0HyQ6Rg69w9k19nviJspaj4yNscGjrHu94sVP+aRm75yEbCh+r2/yR+7q6hux9LVtbuTGBw==}
+ engines: {node: '>=14'}
+ dependencies:
+ xml-name-validator: 4.0.0
+ dev: true
+
/wait-on/6.0.1:
resolution: {integrity: sha512-zht+KASY3usTY5u2LgaNqn/Cd8MukxLGjdcZxT2ns5QzDmTFc4XoWBgC+C/na+sMRZTuVygQoMYwdcVjHnYIVw==}
engines: {node: '>=10.0.0'}
@@ -24386,6 +24495,19 @@ packages:
utf-8-validate:
optional: true
+ /ws/8.12.1:
+ resolution: {integrity: sha512-1qo+M9Ba+xNhPB+YTWUlK6M17brTut5EXbcBaMRN5pH5dFrXz7lzz1ChFSUq3bOUl8yEvSenhHmYUNJxFzdJew==}
+ engines: {node: '>=10.0.0'}
+ peerDependencies:
+ bufferutil: ^4.0.1
+ utf-8-validate: '>=5.0.2'
+ peerDependenciesMeta:
+ bufferutil:
+ optional: true
+ utf-8-validate:
+ optional: true
+ dev: true
+
/ws/8.7.0:
resolution: {integrity: sha512-c2gsP0PRwcLFzUiA8Mkr37/MI7ilIlHQxaEAtd0uNMbVMoy8puJyafRlm0bV9MbGSabUPeLrRRaqIBcFcA2Pqg==}
engines: {node: '>=10.0.0'}