Some libraries can load css files when you import them in component test file. For example:
// test.testplane.tsx
import {Button} from "some-component-library";
describe("suite", {...});
This file executes not only in browser, but also in nodejs environment. Where I get an error like: Unexpected token ... when try to import it. To solve this problem we use pirates + babel, they remove unnecessary imports. But when user import some module (without file extension) we can't figure out if it needs to be ignored in node env or not.
So in order to fix this problem we first require this module and if we get Unexpected token ... error from css file then we remove it.
What is done
Some libraries can load css files when you import them in component test file. For example:
This file executes not only in browser, but also in nodejs environment. Where I get an error like:
Unexpected token ...
when try to import it. To solve this problem we use pirates + babel, they remove unnecessary imports. But when user import some module (without file extension) we can't figure out if it needs to be ignored in node env or not.So in order to fix this problem we first require this module and if we get
Unexpected token ...
error from css file then we remove it.