Skip to content

Instantly share code, notes, and snippets.

View ManfredHu's full-sized avatar
💭
I may be slow to respond.

ManfredHu ManfredHu

💭
I may be slow to respond.
View GitHub Profile
@ManfredHu
ManfredHu / custom-vscode-snippets.json
Last active November 16, 2022 02:41
rfc rfcd Auto to Create React Function Components
{
"Typescript default React component": {
"prefix": "rfcd",
"body": [
"import React, { FC } from 'react'",
"",
"interface ${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/g}Props {",
" $1",
"}",
"",
@ManfredHu
ManfredHu / base64ToImage.ts
Last active July 24, 2021 07:24
base64 to image,兼容各种svg,png,jpeg,jpg,webp,gif
import fs from 'fs'
// 转化Data URI scheme to image file
const typeToExtName: Record<string, string> = {
'jpeg': '.jpeg',
'jpg': '.jpg',
'png': '.png',
'svg+xml': '.svg',
'gif': '.gif',
'webp': '.webp'
@ManfredHu
ManfredHu / getUsedPages.spec.js
Last active January 9, 2024 07:05
小程序自动化获取所有pages截图
// 获取所有pages的截图以便确认是否页面还有用
// 1. 安装 npm i miniprogram-automator jest -D
// 2. 项目根目录 node跑本文件
// 3. 最好package.json加入test命令
/* eslint-env jest */
const automator = require('miniprogram-automator');
const path = require('path');
@ManfredHu
ManfredHu / e2e-shadowdom.md
Created December 20, 2018 15:16 — forked from ChadKillingsworth/e2e-shadowdom.md
Selenium Testing with Shadow DOM

End-to-end Testing with Shadow DOM

As the web component specs continue to be developed, there has been little information on how to test them. In particular the /deep/ combinator has been deprecated in Shadow DOM 1.0. This is particularly painful since most end-to-end testing frameworks rely on elements being discoverable by XPath or calls to querySelector. Elements in Shadow DOM are selectable by neither.

WebDriver.io

Webdriver.io has the standard actions by selectors, but also allows browser executable scripts to return an element