jenniferabowd / jest_webpack_example

MIT License
63 stars 25 forks source link

import sweetalert2 css error #4

Closed mqliutie closed 6 years ago

mqliutie commented 6 years ago

in teamAmerica.test.js I added one line

import swal from 'sweetalert2';

and

npm run test

//red color messages seem there is an error @keyframes swal2-rotate-loading { 0% { -webkit-transform: rotate(0deg); transform: rotate(0deg); } 100% { -webkit-transform: rotate(360deg); transform: rotate(360deg); } }

Test Suites: 1 passed, 1 total Tests: 1 passed, 1 total Snapshots: 1 passed, 1 total

Is this successful?

jenniferabowd commented 6 years ago

@mqliutie It didn't break the tests. I would call that successful, but I'm not sure what your goal is.

mqliutie commented 6 years ago

Test is successful but there is full of screen tip of the css

Now my solution is using webpack alias import this plugin and test set global variable to using another plugin that is no css in js.

This plugin not import any css file but add stylesheet to head element. Show you below

if (typeof document !== "undefined"){!function(e,t){var n=e.createElement("style");if(e.getElementsByTagName("head")[0].appendChild(n),n.styleSheet)n.styleSheet.disabled||(n.styleSheet.cssText=t);else try{n.innerHTML=t}catch(e){n.innerText=t}}(document,"@-webkit-keyframes swal2-show {\n" +
"  0% {\n" +
"    -webkit-transform: scale(0.7);\n" +
"            transform: scale(0.7); }\n" +
"  45% {\n" +
"    -webkit-transform: scale(1.05);\n" +
"            transform: scale(1.05); }\n" +
"  80% {\n" +
"    -webkit-transform: scale(0.95);\n" +
"            transform: scale(0.95); }\n" +
"  100% {\n" +
"    -webkit-transform: scale(1);\n" +
"            transform: scale(1); } }\n" +

In jest imported js I removed these code

jenniferabowd commented 6 years ago

I think this is unrelated to Jest. I think people who know sweetalert2 can help you better.

mqliutie commented 6 years ago

Thanks for your help