Skip to content

Instantly share code, notes, and snippets.

@aslushnikov
Created September 8, 2020 23:13
Show Gist options
  • Select an option

  • Save aslushnikov/614e69101c3dcc93d417ae13fd12a721 to your computer and use it in GitHub Desktop.

Select an option

Save aslushnikov/614e69101c3dcc93d417ae13fd12a721 to your computer and use it in GitHub Desktop.

Revisions

  1. aslushnikov created this gist Sep 8, 2020.
    40 changes: 40 additions & 0 deletions screencast-bug.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,40 @@
    const playwright = require('.');
    const path = require('path');
    const fs = require('fs');

    (async () => {
    const browser = await playwright.chromium.launch({
    _videosPath: __dirname,
    });
    const context = await browser.newContext({
    _recordVideos: {width: 320, height: 240},
    });

    const [video] = await Promise.all([
    new Promise(r => context.on('page', page => page.on('_videostarted', r))),
    context.newPage(),
    ]);
    /*
    // The following doesn't work so we had to do ugly promise all above ^^
    const page = await context.newPage();
    const video = await page.waitForEvent('_videostarted');
    */

    // Record a bit of screencast.
    await new Promise(x => setTimeout(x, 1000));

    const [videoFile] = await Promise.all([
    video.path(),
    context.close(),
    ]);
    await browser.close();

    if (!fs.existsSync(videoFile)) {
    console.log('ERROR: Screencast is missing!');
    process.exit(1);
    }
    console.log('SUCCESS: screencast at ' + videoFile);
    })();