Skip to content

🎥 Make videos programmatically with React

tests: use jest expect().toThrow syntax

SkyezerFoxbd9a16b52258
diff --git a/TESTING.md b/TESTING.md
index 4530f6102b..28fd4ae54d 100644
--- a/TESTING.md
+++ b/TESTING.md
@@ -4,10 +4,10 @@ For general information concerning contribution, please consult [CONTRIBUTION.md
### Core Coverage
-![statements](https://img.shields.io/badge/Coverage_statements-75.96%25-yellow.svg)
-![branches](https://img.shields.io/badge/Coverage_branches-69.84%25-red.svg)
-![functions](https://img.shields.io/badge/Coverage_functions-57.28%25-red.svg)
-![lines](https://img.shields.io/badge/Coverage_lines-74.74%25-yellow.svg)
+![statements](https://img.shields.io/badge/Coverage_statements-76.19%25-yellow.svg)
+![branches](https://img.shields.io/badge/Coverage_branches-69.86%25-red.svg)
+![functions](https://img.shields.io/badge/Coverage_functions-57.25%25-red.svg)
+![lines](https://img.shields.io/badge/Coverage_lines-74.97%25-yellow.svg)
### Running tests
diff --git a/packages/player/src/test/validate-prop.test.tsx b/packages/player/src/test/validate-prop.test.tsx
index 08e8cde6f4..ecef88afad 100644
--- a/packages/player/src/test/validate-prop.test.tsx
+++ b/packages/player/src/test/validate-prop.test.tsx
@@ -190,16 +190,7 @@ test('playbackRate of undefined should be okay', () => {
});
test('passing in <Composition /> instance should not be possible', () => {
- const compositionProps = {
- id: 'HelloWorld',
- width: 500,
- height: 400,
- fps: 30,
- durationInFrames: 500,
- component: HelloWorld,
- };
- let threwError = false;
- try {
+ expect(() => {
render(
<Player
compositionWidth={500}
@@ -219,26 +210,9 @@ test('passing in <Composition /> instance should not be possible', () => {
}}
/>
);
- render(
- <Player
- compositionWidth={500}
- compositionHeight={400}
- fps={30}
- durationInFrames={500}
- component={() => <Composition {...compositionProps} />}
- controls
- showVolumeControls
- inputProps={compositionProps}
- />
- );
- } catch (e) {
- threwError = true;
- expect((e as Error).message).toMatch(
- /'component' must not be an instance of the '<Composition \\>' component./
- );
- } finally {
- expect(threwError).toBe(true);
- }
+ }).toThrow(
+ /'component' must not be an instance of the '<Composition \\>' component./
+ );
});
test.each([