This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
beforeEach(() => { | |
jest.spyOn(window, 'location', 'get').mockReturnValue({ | |
...window.location, | |
href: 'https://myapp.com' | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"test": "jest --detectOpenHandles --forceExit --coverage --collectCoverageFrom=src/components/common/**/*.{js,jsx,ts,tsx} src/components/common/", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
process.env.npm_package_name | |
process.env.npm_package_... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as utils from '../utils'; | |
utils.isSomething = jest.fn(() => true); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const utilityObj = require('../../utils/obj'); | |
jest.mock('../../utils/obj', () => { | |
return { | |
...jest.requireActual(''../../utils/obj'), | |
getDefaultOptions: jest.fn((req, path) => { | |
console.log('mock', path) | |
return // mocked stuff | |
}), | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { SOME_VALUE } from '../constants'; | |
jest.mock('../constants', () => ({ SOME_VALUE: 'abc123test' })); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function enummaker(obj = {}) { | |
let newEnum = obj; | |
newEnum[Symbol.iterator] = function() { | |
let i = 0; | |
let keys = Object.keys(this); | |
return { | |
next: function() { | |
let value = keys[i]; | |
i++; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function singletonMaker(key, klassname, namespace) { | |
if (!window[namespace]) { | |
window[namespace] = {}; | |
} | |
const keySymbol = Symbol.for(key); | |
const globalSymbols = Object.getOwnPropertySymbols(namespace); | |
const hasKey = (globalSymbols.indexOf(keySymbol) > -1); | |
if (!hasKey) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const mutationObserver = new MutationObserver((e) => { | |
if (e[0].removedNodes) { | |
console.log('%cremoved nodes %o', 'color:aquamarine', e[0].removedNodes); | |
} | |
}); | |
// watch just the child nodes | |
mutationObserver.observe(document.querySelector('main'), { childList: true }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<snippet> | |
<content><![CDATA[ | |
gulp.task('${1}', function(){ | |
gulp.${2:src}(${3}) | |
.pipe(${4}); | |
}); | |
]]></content> | |
<!-- Optional: Set a tabTrigger to define how to trigger the snippet --> | |
<tabTrigger>gt</tabTrigger> | |
<!-- Optional: Set a scope to limit where the snippet will trigger --> |
NewerOlder