forked from atomiks/tippyjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.js
42 lines (32 loc) · 945 Bytes
/
setup.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import 'expect-puppeteer';
import tippy from '../src';
import {render} from '../src/template';
import {cleanDocumentBody} from './utils';
import {toMatchImageSnapshot} from 'jest-image-snapshot';
import {resetVisitedMessages} from '../src/validation';
expect.extend({toMatchImageSnapshot});
tippy.setDefaultProps({
render,
content: '__DEFAULT_TEST_CONTENT__',
duration: 0,
delay: 0,
});
jest.useFakeTimers();
// We want to use macrotask timers that can be mocked by Jest
global.Promise = require('promise');
global.requestAnimationFrame = (cb) => cb();
// Prevents console from spamming test output while still allowing for debugging
// while writing tests
global.console = {
log: console.log,
warn: jest.fn(),
error: jest.fn(),
};
afterEach(() => {
global.console.warn.mockReset();
global.console.error.mockReset();
resetVisitedMessages();
if (typeof document !== 'undefined') {
cleanDocumentBody();
}
});