Skip to content

Instantly share code, notes, and snippets.

View zeropaper's full-sized avatar
💅
I may be slow to respond.

Valentin Vago zeropaper

💅
I may be slow to respond.
View GitHub Profile
@zeropaper
zeropaper / e2e.documentation-template.js
Last active September 24, 2019 08:29
puppeteer tips and tricks
const renderScreenshot = ({
title = '',
slug = '',
pageIndex = 0,
screenshotPath = '',
description = '',
}) => `<figure id="${slug}-${pageIndex}">
<img src="${screenshotPath}" title="${title}" />
<figcaption>${description}</figcaption>
</figure>`;
const renderScreenshot = ({
title = '',
slug = '',
pageIndex = 0,
screenshotPath = '',
description = '',
}) => `<figure id="${slug}-${pageIndex}">
<img src="${screenshotPath}" title="${title}" />
<figcaption>${description}</figcaption>
</figure>`;
@zeropaper
zeropaper / jest-environment.js
Last active October 29, 2019 10:54
Example of Jest environment to generate documentation
// NOTE: this code is not intended to work as-is,
// it needs to be adapted to your setup/environment
const NodeEnvironment = require('jest-environment-node');
const puppeteer = require('puppeteer');
const path = require('path');
const rimraf = require('rimraf');
const mkdirp = require('mkdirp');
const httpServer = require('http-server');
// very useful tool to turn a callback function into a async function ;)
const renderScreenshot = ({
title = '',
slug = '',
pageIndex = 0,
screenshotPath = '',
description = '',
}) => `<figure id="${slug}-${pageIndex}">
<img src="${screenshotPath}" title="${title}" />
<figcaption>${description}</figcaption>
</figure>`;
describe('Some interaction', () => {
// … do something
await writeDocs({
info: {
title: 'Title of the "step"',
},
screenshots: [
// takes a screenshot of the first (0) browser page
{
@zeropaper
zeropaper / dump_to_file.php
Created August 13, 2022 09:03
instead of using dd()
<?php
function dump_to_file(...$any) {
ob_start();
var_dump(...$any);
file_put_contents('log.txt', ob_get_clean(), FILE_APPEND);
}