-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[chore] resolve outdated todos #2210
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice cleanup!
@@ -1,7 +1,6 @@ | |||
import { getContext } from 'svelte'; | |||
|
|||
// const ssr = (import.meta as any).env.SSR; | |||
const ssr = typeof window === 'undefined'; // TODO why doesn't previous line work in build? | |||
const ssr = import.meta.env.SSR; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This broke some test mocks on our end. What's the best way to get import.meta.env
to be defined in a non-vite context such as Jest or another test runner?
Edit: That's with a setup similar to this example except I think ours is using jest's esm support.
Overall not a huge deal, as there are multiple workarounds. Ideally there would be a project similar to vite-jest
that would spin up Svelte Kit. I was just wondering if there was a recommended approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there's an issue about this. it's been one of the things to figure out before 1.0: #1485
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wallw-bits @benmccann
I noticed this breaking tests for me as well - I think something like
import { browser } from './env.js'
const ssr = !browser
would do the trick, as then you can just mock $app/env.js
with
jest.mock('$app/env.js', () => ({
amp: false,
browser: true, // or false for testing ssr
dev: true,
mode: 'test'
}))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR made: #2353
Resolve some outdated TODOs that we can safely remove as we're approaching 1.0