Skip to content

Instantly share code, notes, and snippets.

View markusbergh's full-sized avatar
👋

Markus Bergh markusbergh

👋
View GitHub Profile
@markusbergh
markusbergh / mockFetch.js
Created January 10, 2021 00:31
Mocking Fetch API by using Jest
/**
* Minimal mocking
*/
// `global` is available in both node and browser environment
/*
global.fetch = () =>
Promise.resolve({
json: () => Promise.resolve({
@markusbergh
markusbergh / component.js
Created January 10, 2018 09:51
Highlight.js with tree shaking
// Core import
import highlightjs from 'highlight.js/lib/highlight'
// Languages import
import javascript from 'highlight.js/lib/languages/javascript'
import bash from 'highlight.js/lib/languages/bash'
import yaml from 'highlight.js/lib/languages/yaml'
// Register languages
highlightjs.registerLanguage('javascript', javascript)