web-renderer-test について
RemotionのWebレンダラーの実装変更に合わせてテストを保守するスキルです。vitestによるビジュアルスナップショットテストと、フィクスチャを使う手順を扱います。
主な機能
- 01実装変更に応じたレンダラーテストの更新
- 02vitestによるビジュアルスナップショットテスト
- 03テスト用フィクスチャの利用
- 04プレビュー用フィクスチャの登録
活用シーン
- 01レンダラー変更後のテスト調整
- 02テスト更新時のフィクスチャ確認
インストール
コマンドをコピーしてターミナルで実行します。
$
npx skills add https:/ / github.com/ remotion-dev/ remotion --skill web-renderer-testインストール後、Claude Code で/web-renderer-testを入力して読み込まれたか確認します。
詳細
実装の変更に応じて、既存のウェブレンダラーのテストを更新する際にこのスキルを使用してください。ユーザーから明示的な依頼があった場合にのみ、新しいテストを追加してください。
ウェブレンダラーは packages/web-renderer にあり、テストスイートは packages/web-renderer/src/test にあります。
vitest を使用したビジュアルスナップショットテストを行います。たとえば、次のコマンドでテストファイルを実行できます。
bunx vitest src/test/video.test.tsx
例
各テストは、packages/web-renderer/src/test/fixtures にあるフィクスチャを使います。
たとえば、フィクスチャは次のようになります。
import {AbsoluteFill} from 'remotion';
const Component: React.FC = () => {
return (
<AbsoluteFill
style={{
justifyContent: 'center',
alignItems: 'center',
}}
>
<div
style={{
backgroundColor: 'red',
width: 100,
height: 100,
borderRadius: 20,
}}
/>
</AbsoluteFill>
);
};
export const backgroundColor = {
component: Component,
id: 'background-color',
width: 200,
height: 200,
fps: 25,
durationInFrames: 1,
} as const;
対応するテストは次のようになります。
import {test} from 'vitest';
import {renderStillOnWeb} from '../render-still-on-web';
import {backgroundColor} from './fixtures/background-color';
import {testImage} from './utils';
test('should render background-color', async () => {
const blob = await renderStillOnWeb({
licenseKey: 'free-license',
composition: backgroundColor,
frame: 0,
inputProps: {},
imageFormat: 'png',
});
await testImage({blob, testId: 'background-color'});
});
新しいテストの追加
packages/web-renderer/src/test/fixturesに新しいフィクスチャを追加します。- 重要:プレビューできるように、
packages/web-renderer/src/test/Root.tsxにフィクスチャを追加します。 packages/web-renderer/src/testに新しいテストを追加します。bunx vitest src/test/video.test.tsxを実行してテストを実行します。- 重要:新たにサポートされたプロパティを反映するため、
packages/docs/docs/client-side-rendering/limitations.mdxを更新します。
コメント
Markdown 対応