@@ -6,7 +6,11 @@ function _setupTests(testType) {
66 let messageFromWorker = null ;
77
88 function consoleLogToShell ( message ) {
9- return window . __TAURI__ . invoke ( "console_log" , { message} ) ;
9+ if ( window . __TAURI__ ) {
10+ return window . __TAURI__ . invoke ( "console_log" , { message} ) ;
11+ } else if ( window . electronAPI ) {
12+ return window . electronAPI . consoleLog ( message ) ;
13+ }
1014 }
1115
1216 async function _clean ( ) {
@@ -28,8 +32,8 @@ function _setupTests(testType) {
2832 }
2933
3034 async function _requestWritePerm ( ) {
31- if ( window . __TAURI__ || testPath !== window . mountTestPath ) {
32- // fs access apis not tested in tauri
35+ if ( window . __TAURI__ || window . __ELECTRON__ || testPath !== window . mountTestPath ) {
36+ // fs access apis not tested in tauri/electron
3337 return ;
3438 }
3539 return new Promise ( ( resolve , reject ) => {
@@ -45,13 +49,19 @@ function _setupTests(testType) {
4549 }
4650
4751 async function _setupTestPath ( ) {
52+ let appDataDir ;
4853 switch ( testType ) {
4954 case TEST_TYPE_FS_ACCESS : testPath = window . mountTestPath ; break ;
5055 case TEST_TYPE_FILER : testPath = window . virtualTestPath ; break ;
5156 case TEST_TYPE_TAURI_WS :
5257 await window . waitForTrue ( ( ) => { return window . isNodeSetup ; } , 10000 ) ;
5358 fs . forceUseNodeWSEndpoint ( true ) ;
54- testPath = fs . getTauriVirtualPath ( `${ await window . __TAURI__ . path . appLocalDataDir ( ) } test-phoenix-fs` ) ;
59+ if ( window . __TAURI__ ) {
60+ appDataDir = await window . __TAURI__ . path . appLocalDataDir ( ) ;
61+ } else if ( window . electronAPI ) {
62+ appDataDir = await window . electronAPI . getAppDataDir ( ) ;
63+ }
64+ testPath = fs . getTauriVirtualPath ( `${ appDataDir } test-phoenix-fs` ) ;
5565 consoleLogToShell ( "using tauri websocket test path: " + testPath ) ;
5666 break ;
5767 default : throw new Error ( "unknown file system impl" ) ;
@@ -171,16 +181,16 @@ describe(`web worker filer tests`, function () {
171181 _setupTests ( TEST_TYPE_FILER ) ;
172182} ) ;
173183
174- if ( window . __TAURI__ ) {
184+ if ( window . __TAURI__ || window . __ELECTRON__ ) {
175185 describe ( `web worker Tauri WS tests` , function ( ) {
176186 _setupTests ( TEST_TYPE_TAURI_WS ) ;
177187 } ) ;
178188}
179189
180190if ( window . supportsFsAccessAPIs ) {
181191 describe ( `web worker fs access tests` , function ( ) {
182- if ( window . __TAURI__ ) {
183- it ( `fs access tests are disabled in tauri` , function ( ) { } ) ;
192+ if ( window . __TAURI__ || window . __ELECTRON__ ) {
193+ it ( `fs access tests are disabled in tauri/electron ` , function ( ) { } ) ;
184194 return ;
185195 } else {
186196 _setupTests ( TEST_TYPE_FS_ACCESS ) ;
0 commit comments