Files
rrweb/packages/rrvideo/test/cli.test.ts
Justin Halsall d70bcf45d7 build(rrvideo): upgrade playwright from 1.32.1 to 1.56.1 (#1761)
* build(rrvideo): upgrade playwright from 1.32.1 to 1.56.1

Update playwright dependency to latest version and refactor test execution options to use a shared configuration with increased timeout for stability.
2026-04-01 12:00:00 +08:00

49 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'));
});
const execOptions = { stdio: 'pipe', timeout: 60_000 } as const;
it('should throw error without input path', () => {
expect(() => {
execSync('node ./build/cli.js', execOptions);
}).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',
execOptions,
);
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}`,
execOptions,
);
expect(fs.existsSync(outputFile)).toBe(true);
fs.removeSync(outputFile);
});
});