gemini-testing / testplane

Testplane (ex-hermione) browser test runner based on mocha and wdio
https://testplane.io
MIT License
720 stars 63 forks source link

fix(component-testing): correctly import components with css from third party libraries #1023

Closed DudaGod closed 1 month ago

DudaGod commented 1 month ago

What is done

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.