Test lit-element webcomponent with Karma

情到浓时终转凉″ 提交于 2021-01-29 11:28:51

问题


I am trying to create a blank project, like a template, using lit-html. I wanted to also add some testing capabilities, so i have been trying to get it to work with Karma.

I can run a normal test, like an addition, without any errors, so i think Karma itself is running ok. but i can't run any test involving the webcomponent. I can't import the webcomponent!

i am exporting the webcomponent with: export default class MyComponent ...

and then on the test file i am importing it with: import MyComponent from 'pathToComponent/MyComponent'

When i run the test i get:

Error loading test file: /test/example.test.js
TypeError: Failed to fetch dynamically imported module: http://localhost:9876/base/test/example.test.js

I have it on a github repo here: https://github.com/boguz/rollup-lit-redux, so you can take a better look if you need to see what other packages i have installed.

Any help is very appreciated. Thank you!

来源:https://stackoverflow.com/questions/63836516/test-lit-element-webcomponent-with-karma

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!