You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey folks, my team is trying to migrate our tests from Web Test Runner to Vitest and we have a few tests that are failing due to window.location.pathname. We have Vitest's Browser Mode enabled and noticed it places test metadata onto our path, which I'm assuming is from: (
But our pathname when running our tests results in something like "/__vitest_test__/__test__/2650bfc6-b49a-4c09-868f-44fa8a52c2ae/%2Fpath%2Fto%2Ftest%2Ffile.ts",
Any workarounds or suggestions here since we're not able to mock/redefine window.location? Hoping not to modify our application code and keep this isolated to our tests.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hey folks, my team is trying to migrate our tests from Web Test Runner to Vitest and we have a few tests that are failing due to
window.location.pathname
. We have Vitest's Browser Mode enabled and noticed it places test metadata onto our path, which I'm assuming is from: (vitest/packages/browser/src/client/orchestrator.ts
Lines 94 to 99 in c82387d
Unfortunately, there's cases in our application code that expect
window.location.pathname
to be specific routes e.g.But our pathname when running our tests results in something like
"/__vitest_test__/__test__/2650bfc6-b49a-4c09-868f-44fa8a52c2ae/%2Fpath%2Fto%2Ftest%2Ffile.ts",
Any workarounds or suggestions here since we're not able to mock/redefine
window.location
? Hoping not to modify our application code and keep this isolated to our tests.Beta Was this translation helpful? Give feedback.
All reactions