File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ " @tauri-apps/api " : ' patch:bug'
3+ ---
4+
5+ No longer crashing in tests without mocks when ` clearMocks ` is defined in ` afterEach ` hook.
Original file line number Diff line number Diff line change @@ -152,11 +152,12 @@ export function mockWindows(
152152 *
153153 * @since 1.6.0
154154 */
155- export function mockConvertFileSrc (
156- osName : string
157- ) : void {
155+ export function mockConvertFileSrc ( osName : string ) : void {
158156 window . __TAURI_INTERNALS__ = window . __TAURI_INTERNALS__ ?? { }
159- window . __TAURI_INTERNALS__ . convertFileSrc = function ( filePath , protocol = 'asset' ) {
157+ window . __TAURI_INTERNALS__ . convertFileSrc = function (
158+ filePath ,
159+ protocol = 'asset'
160+ ) {
160161 const path = encodeURIComponent ( filePath )
161162 return osName === 'windows'
162163 ? `http://${ protocol } .localhost/${ path } `
@@ -191,6 +192,10 @@ export function mockConvertFileSrc(
191192 * @since 1.0.0
192193 */
193194export function clearMocks ( ) : void {
195+ if ( typeof window . __TAURI_INTERNALS__ !== 'object' ) {
196+ return
197+ }
198+
194199 // @ts -expect-error "The operand of a 'delete' operator must be optional' does not matter in this case
195200 delete window . __TAURI_INTERNALS__ . convertFileSrc
196201 // @ts -expect-error "The operand of a 'delete' operator must be optional' does not matter in this case
You can’t perform that action at this time.
0 commit comments