UNPKG

1.06 kBJavaScriptView Raw
1/**
2 * Wrapper around setTimeout which executes immediately in visual tests
3 * in order to avoid flaky tests
4 */
5function setStoryTimeout(fn, timeout) {
6 return setTimeout(fn, process.env.IS_VISUAL_TEST ? 0 : timeout);
7}
8
9// adopted this method from Bootstraps utils
10// https://github.com/bootstrap-vue/bootstrap-vue/blob/2fd03f0b1d0cc41f9930078ba8b1c16b10e4ac2f/tests/utils.js#L6
11const waitForAnimationFrame = () => new Promise(resolve => {
12 requestAnimationFrame(resolve);
13});
14const getResetAnimationsCSS = () => `
15 *, *::after, *::before {
16 -webkit-transition: none !important;
17 -moz-transition: none !important;
18 -ms-transition: none !important;
19 -o-transition: none !important;
20 transition: none !important;
21
22 -webkit-animation: none !important;
23 -moz-animation: none !important;
24 -ms-animation: none !important;
25 -o-animation: none !important;
26 animation: none !important;
27 }
28
29 input, textarea {
30 caret-color: transparent !important;
31 }`;
32
33export { getResetAnimationsCSS, setStoryTimeout, waitForAnimationFrame };