ux
ux copied to clipboard
[LiveComponent] Webpack throws 272 errors when testing lib isn't installed
I've included the ux-live-component
library as specified in the README with having my package.json have the filepath to the vendor folder.
"@symfony/ux-live-component": "file:vendor/symfony/ux-live-component/assets",
I happen not to have Jest installed in my project and I end up getting my console spammed with a flood of errors where Webpack is trying to incorporate the testing directory for the library.
...
error in /home/allejo/my-project/vendor/symfony/ux-live-component/assets/test/controller/render.test.ts 10:40:01 PM
[tsl] ERROR in /home/allejo/my-project/vendor/symfony/ux-live-component/assets/test/controller/render.test.ts(101,5)
TS2582: Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha`.
error in /home/allejo/my-project/vendor/symfony/ux-live-component/assets/test/controller/render.test.ts 10:40:01 PM
[tsl] ERROR in /home/allejo/my-project/vendor/symfony/ux-live-component/assets/test/controller/render.test.ts(103,17)
TS2339: Property 'element' does not exist on type 'TestData'.
error in /home/allejo/my-project/vendor/symfony/ux-live-component/assets/test/controller/render.test.ts 10:40:01 PM
[tsl] ERROR in /home/allejo/my-project/vendor/symfony/ux-live-component/assets/test/controller/render.test.ts(120,9)
TS2304: Cannot find name 'expect'.
Entrypoint app [big] 2.83 MiB (210 KiB) = runtime.js 14.6 KiB vendors-node_modules_symfony_stimulus-bridge_dist_index_js-node_modules_bootstrap_dist_js_boo-180201.css 1.08 MiB vendors-node_modules_symfony_stimulus-bridge_dist_index_js-node_modules_bootstrap_dist_js_boo-180201.js 1.46 MiB app.css 10.1 KiB app.js 274 KiB 2 auxiliary assets
webpack compiled with 272 errors
After installing jest
and @types/jest
in my parent project (even though I don't need it), I get some updated errors but still related to running tests.
...
error in /home/allejo/my-project/vendor/symfony/ux-live-component/assets/test/controller/render.test.ts 10:57:28 PM
[tsl] ERROR in /home/allejo/my-project/vendor/symfony/ux-live-component/assets/test/controller/render.test.ts(103,17)
TS2339: Property 'element' does not exist on type 'TestData'.
error in /home/allejo/my-project/vendor/symfony/ux-live-component/assets/test/controller/render.test.ts 10:57:28 PM
[tsl] ERROR in /home/allejo/my-project/vendor/symfony/ux-live-component/assets/test/controller/render.test.ts(120,29)
TS2339: Property 'toHaveTextContent' does not exist on type 'Matchers<void, any>'.
It'd be nice if there was some way for Webpack to ignore the test folder of this library. Installing Jest
Hey!
Hmm, that's very odd - I haven't gotten this error. Is there ANYTHING special about your setup? I guess, you probably have typescript installed and enabled on Encore? Is that correct? Anything else custom?
Cheers!
Hello,
I experienced a similar issue and it was due to Typescript being ran on the vendor files (because the module in node_modules is actually a symbolic link).
You should be able to fix this problem by adding the following configuration in your tsconfig.json file:
{
"exclude": [
"node_modules",
"vendor"
]
}
I can confirm that adding the exclude
to my tsconfig.json
file solved the problem! Maybe this could be documented or included as a magical check/patch during install?
Thank you for this issue. There has not been a lot of activity here for a while. Has this been resolved?
Friendly ping? Should this still be open? I will close if I don't hear anything.
Hey,
I didn't hear anything so I'm going to close it. Feel free to comment if this is still relevant, I can always reopen!