-
Notifications
You must be signed in to change notification settings - Fork 184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unexpected token when using @testing-library/svelte #140
Comments
Hi @samedro! It's difficult to say what might have gone wrong with your test setup without seeing your project. Could you share a minimal reproducible example that we can ideally clone and try? The issue is that your code has not been transpiled before testing and Jest doesn't know what to do with the |
I'm also getting this issue with SSR. Does the code need to be transpiled for SSR? Edit my mistake, I had an |
@EmilTholin the problem is Babel setups doesn't transpile files within |
There is no build step before publishing, just the raw svelte and es6 syntax files. |
I was able to get past this error by adding a transformIgnorePatterns in my jest.config.js jest.config.js
babel.config.js
However, this led to another error from
I came across this thread while looking for a solution but haven't been able to solve it. |
@agrawal-rohit Having the same issue:
Have you found a solution? |
Problem
...
const { base } = getContext(ROUTER); // <-- this will assigned undefined
const location = getContext(LOCATION); // <-- same here too!
const dispatch = createEventDispatcher();
...
...
setContext(ROUTER, {
activeRoute,
base,
routerBase,
registerRoute,
unregisterRoute
});
</script>
... In the
Hence you'll need to configure your tests to pass down a WorkaroundIt's not a nice workaround, as I'm currently using a package to convert my test files from
You'd expect something like; render(
<Router>
<Link to="/"></Link>
</Router>,
) |
Hi,
I'm new to svelte, and I'm trying to add some unit tests to my application. I followed explanations on how to setup the testing library, but when I execute the "npm test" command on a component that imports for exemple :
import { link } from 'svelte-routing';
, there is this error :Could someone help me on this one ?
Thanks.
The text was updated successfully, but these errors were encountered: