Skip to content

Instantly share code, notes, and snippets.

View mahowa's full-sized avatar
👾

Matt Howa mahowa

👾
View GitHub Profile
@mahowa
mahowa / adBlockCheck.js
Created June 26, 2019 15:13
Easily check if adblock is on
adsBlocked = async () => {
const testURL =
'https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js';
const myInit = {
method: 'HEAD',
mode: 'no-cors',
};
const myRequest = new Request(testURL, myInit);
@mahowa
mahowa / router.js
Last active February 19, 2020 22:19
Next.js router mock
// Place in __mocks__/next/
import React, { useState } from 'react';
let route = '';
// Set before running test
export const setRoute = _route => {
route = _route;
};
/*
@mahowa
mahowa / accessible-link.js
Last active March 25, 2020 16:27
React Accessible link. Outline only when keyboard focus (emotion.js/styled-components.js)
@mahowa
mahowa / setupTests.js
Created February 25, 2020 20:49
Jest test for console.warn & console.error
// In case you are tired of seeing warning and error messages in your tests add these
// few lines of code to your setupTests.js file.
//
// Any test that outputs console.error or console.warn will fail allowing you to easily
// identify where the log came from so you can address it accordingly
const spyError = jest.spyOn(global.console, 'error');
const spyWarn = jest.spyOn(global.console, 'warn');
afterEach(() => {