Skip to content

Instantly share code, notes, and snippets.

@AshCoolman
AshCoolman / label.js
Created February 15, 2018 11:57
Label to help with jest snapshots
// Jests dont write to file in chron order, prefix with number helps
let count = 0;
const label = (tmpl, ...val) => {
val.reverse();
return `${
count++ // eslint-disable-line
}. ${
tmpl.reduce((p, c) => p + c + (val.length ? val.pop() : ''), '')
}`;
@AshCoolman
AshCoolman / createNumberFormatFromNumberToLocalString.js
Created February 12, 2018 18:06
Create number format from Number.prototype.toLocaleString
// The following must be executed in browser, and can be pasted into
//
// WHY?
// 1. Browser support is a bit spotty
// 2. Testing with node framework made harder as node doesn't come with internationalistion (full-icu) data by default
// 3. Int shim is ~56Kb https://github.com/andyearnshaw/Intl.js/blob/master/dist/Intl.min.js. This is ~7kb
var getNumberFormatFromIso2 = (iso) => {
let thousandsSeparatorSymbol;
@AshCoolman
AshCoolman / Snippets.md
Last active March 28, 2018 10:57
Snippets

Glob

python << EOF
import glob
for name in glob.glob('/*'):
  print(name)
EOF
@AshCoolman
AshCoolman / findAllTests.sh
Created February 1, 2018 10:57
Lerna repo test finder
# Easy to use mocha globs to find test files in this structure:
#
# └─src
# │ └─index.spec.js
# └─.dist
# │ └─index.spec.js
# └─node_modules
# └─(...various...)
#
# With this structure, it got very difficult with include+exclude globs (perhaps impossible)
@AshCoolman
AshCoolman / Jenkins cheat sheet.md
Last active January 31, 2018 10:34
Jenkins cheatsheet.md

Sections

Contains Directives or Steps

  • agent - where env will execute
  • post - run once Pipeline or stage has run. Supports blocks always (regardless), changed (different completion status), failure, success, unstable (Pipeline or stage run status == "unstable" e.g. test failures), aborted
@AshCoolman
AshCoolman / jest.md
Created January 25, 2018 11:05 — forked from vojty/jest.md
Jest cheat sheet

Jest cheat shiiiit

Expect

expect.any(constructor) // expect(callback).toBe(expect.any(Function))
expect.assertions(number) // total count of expected assertions, useful for async tests
.not
.resolves
.rejects
.toBe(value)

.toHaveBeenCalled()

@AshCoolman
AshCoolman / integration.test.js
Created January 19, 2018 12:11
Differencify live vs test
import Differencify from '../index';
const differencify = new Differencify({ debug: true });
describe('Differencify', async () => {
let target;
let page;
beforeAll(async () => {
await differencify.launchBrowser({ args: ['--no-sandbox', '--disable-setuid-sandbox'], headless: false });
target = differencify.init({ chain: false });
@AshCoolman
AshCoolman / gen-changelog.sh
Created January 17, 2018 17:22
Generate changelog
echo ""
echo "# Change log"
echo ""
git log `git describe --tags --abbrev=0`..HEAD --oneline --pretty=format:"* %s"
echo ""
@AshCoolman
AshCoolman / lerna-find-all-tests.sh
Created January 17, 2018 17:18
lerna find all tests
find . \
\( -name '*.spec.js' -o -name '*.spec.jsx' \) \
-and \
\( \
\( -not -path "*node_modules*" \) \
-and \
\( -not -path "*.dist*" \) \
\)