Files
rrweb/packages/rrvideo/test/cli.test.ts
Yun Feng 937e3b42ce rrvideo: improve the video quality and add a progress bar for the CLI tool (#1197)
* refactor rrvideo: use playwright rather than puppeteer

* add a progress bar for the tool

* add tests for cli.ts

* fix build error

* add change log

* update readme file

* Apply a scaling method to improve the resolution of the output video
2026-04-01 12:00:00 +08:00

46 lines
1.4 KiB
TypeScript

import { execSync } from 'child_process';
import * as fs from 'fs-extra';
import * as path from 'path';
import exampleEvents from './events/example';
describe('should be able to run cli', () => {
beforeAll(() => {
fs.mkdirSync(path.resolve(__dirname, './generated'));
fs.writeJsonSync(
path.resolve(__dirname, './generated/example.json'),
exampleEvents,
{
spaces: 2,
},
);
});
afterAll(async () => {
await fs.remove(path.resolve(__dirname, './generated'));
});
it('should throw error without input path', () => {
expect(() => {
execSync('node ./build/cli.js', { stdio: 'pipe' });
}).toThrowError(/.*please pass --input to your rrweb events file.*/);
});
it('should generate a video without output path', () => {
execSync('node ./build/cli.js --input ./test/generated/example.json', {
stdio: 'pipe',
});
const outputFile = path.resolve(__dirname, '../rrvideo-output.webm');
expect(fs.existsSync(outputFile)).toBe(true);
fs.removeSync(outputFile);
});
it('should generate a video with specific output path', () => {
const outputFile = path.resolve(__dirname, './generated/output.webm');
execSync(
`node ./build/cli.js --input ./test/generated/example.json --output ${outputFile}`,
{ stdio: 'pipe' },
);
expect(fs.existsSync(outputFile)).toBe(true);
fs.removeSync(outputFile);
});
});