g-plane / swc-plugin-react-remove-properties

SWC plugin for removing React properties.
https://www.npmjs.com/package/swc-plugin-react-remove-properties
MIT License
12 stars 1 forks source link

Not working using swc/jest #2

Closed wuifdesign closed 1 year ago

wuifdesign commented 1 year ago

If i use swc/jest and i have this plugin configured .swcrc to use this plugin the tests will fails with:

Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)

g-plane commented 1 year ago

Can you create a reproduction repository?

wuifdesign commented 1 year ago

@g-plane repo here: https://github.com/wuifdesign/swc-plugin-react-remove-properties-bug

npm run test works fine, but if you add swc-plugin-react-remove-properties it failes with:

> swc-plugin-react-remove-properties-bug@1.0.0 test
> jest

 RUNS  src/app.spec.tsx

Process finished with exit code -1073741819 (0xC0000005)

If you add/remove the swc-plugin-react-remove-properties in the .swcrc you have to run jest --clearCache otherwise the result will be cached.

This plugin should be ignored for tests anyway, as the data-testid should not be removed when running test, otherwise tests will fail.

g-plane commented 1 year ago

Plugin shouldn't concern about the environment. That is, it doesn't care whether it's running in testing or not.

wuifdesign commented 1 year ago

but there is no way to exclude a plugin via .swcrc just for testing, but keep it included for build. or did i miss something? so this plugin can't be used if you want to use tests in your project.

g-plane commented 1 year ago

What about try using different config files?

wuifdesign commented 1 year ago

how do you use different config files in swc? i never found something like this

g-plane commented 1 year ago

I don't know, sorry.

wuifdesign commented 1 year ago

i think there is currently no way to do something like that. So it is sadly to say: "if you want to use swc/jest you can't use this repo" :(

even if it shouldnt be used in tests anyway.

g-plane commented 1 year ago

@swc/jest has documented about using different config files: https://github.com/swc-project/jest#usage .

wuifdesign commented 1 year ago

thx, i will try that. but i think this issue is closed as you will not implement automatic disabling for tests, but you may want to include this stuff for swc/jest in the docs.