svelte-range-slider-pips
svelte-range-slider-pips copied to clipboard
[question] TypeError: SvelteRangeSliderPips is not a constructor
Describe the bug
Testing a svelte component that include RangeSlider
does not works. I have an error :
TypeError: SvelteRangeSliderPips is not a constructor
.
I'm testing a "classic" implementation with :
<script>
import RangeSlider from "svelte-range-slider-pips";
</script>
<RangeSlider values={[50]} pips />
If I try to fork project and implement some tests with jest and testing library, I don't manage to make it works. Getting error :
Unrecognized option 'sourcemap'
.
To Reproduce
Just try to test RangeSlider
component in a svelte app.
For the second problem, you can fork : https://github.com/lpoupet/svelte-range-slider-pips
Steps to reproduce the behavior:
Run npm run test
Expected behavior No error
hi @lpoupet
I don't quite follow what you mean by "classic". Are you meaning that you simply trying to import into a Svelte project? And if so, Svelte 2 or Svelte 3, or SvelteKit ?
Anyway, I cannot replicate, see; https://stackblitz.com/edit/vitejs-vite-4gezgs?file=src%2FApp.svelte&terminal=dev for example. Please can you produce a reduced test case for me?
Secondly, I'm not sure what your issue is with sourcemap, but I think it's unrelated to this component and is an issue with the way you're loading Svelte. as sourcemap
is a Svelte option, not a RangeSlider
option. (https://svelte.dev/docs#compile-time-svelte-compile)
Hello,
The issue is, when we use the testing-library with a component importing the svelte-range-slider-pips
<script>
import RangeSlider from 'svelte-range-slider-pips';
</script>
We have an error TypeError: RangeSlider is not a constructor
.
The workaround is specify the /src
path on the import
<script>
import RangeSlider from 'svelte-range-slider-pips/src';
</script>
Because the testing-library will target the main path on the package.json.