Skip to content

Instantly share code, notes, and snippets.

View Robdel12's full-sized avatar
🏁
Making a PitStop

Robert DeLuca Robdel12

🏁
Making a PitStop
View GitHub Profile
const PercyScript = require('@percy/script');
const fs = require('fs');
const path = require('path');
const directories = [
path.resolve(__dirname, '../src/components/elements'),
path.resolve(__dirname, '../src/components/patterns'),
path.resolve(__dirname, '../src/components/templates'),
];
const PercyScript = require("@percy/script");
const fs = require("fs");
const path = require("path");
const directories = [
{
type: "Element",
path: path.resolve(__dirname, "src/components/elements")
},
{
events:
enabled: true
subscriptions:
- command: node ~/scripts/turn-off-printer.js
event: PrintDone
type: system
system:
actions:
- name: Turn off printer
action: turnoff
@Robdel12
Robdel12 / toggle-plug.js
Last active February 25, 2022 08:43
Toggle Meross Plug from Node
"use strict";
// TODO: I know, I know, don't use request...
const request = require("request");
// Wrap request with a promise to make it awaitable
function doRequest(options) {
return new Promise(function(resolve, reject) {
request(options, function(error, res, body) {
if (!error && res.statusCode == 200) {
pipelines:
default:
- step:
name: Visual test
image: circleci/node:8-browsers
script:
- node -v
- npm -v
- npx percy exec -- node ./snapshots.js
{
"devDependecies": {
},
"percy": {
"version": 1,
"agent": {
"request-headers": {
"Authentication": "Basic c3RnOnN0ZzEyMw=="
}
@Robdel12
Robdel12 / cypress-interactor.js
Created July 15, 2019 14:33
Interactor.js + Cypress
beforeEach(function() {
// Tell Interactor where the applications DOM is
// since Cypress runs the test specs in an isolated iframe (away from the app DOM)
cy.window().then(remoteWindow => {
Object.defineProperty(Interactor.prototype, "$dom", {
get() {
return remoteWindow;
}
});
});
export default function getExampleDOM() {
// This is just a raw example of setting up some DOM
// that we can interact with. Swap this with your UI
// framework of choice 😉
let div = document.createElement("div");
div.innerHTML = `
<label for="username">Username</label>
<input id="username" />
<button>Print Username</button>
import { mount } from 'testing-hooks/react-dom';
import { type } from 'interactor.js';
import MyInputComponent from './MyInputComponent';
describe('MyInputComponent', () => {
beforeEach(async () => {
await mount(
<MyInputComponent {...props} />
);
});
@Robdel12
Robdel12 / lambda.js
Created May 2, 2019 14:38 — forked from luketheobscure/lambda.js
Percy Bitbucket AWS Lambda
const https = require('https');
const AUTHORIZATION = ''; // base 64 of user:password
const BITBUCKET_USER = ''; // either the user or the org that owns the repo
const PERCY_USER = ''; // the name of your percy user or org
exports.handler = (event, context, callback) => {
/**
We need to post to a URL like this:
https://api.bitbucket.org/2.0/repositories/<user>/<repo>/commit/<hash>/statuses/build