diff --git a/packages/nocodb-nest/src/modules/test/TestResetService/resetMetaSakilaSqliteProject.ts b/packages/nocodb-nest/src/modules/test/TestResetService/resetMetaSakilaSqliteProject.ts index 3afce9b44a..8425b00050 100644 --- a/packages/nocodb-nest/src/modules/test/TestResetService/resetMetaSakilaSqliteProject.ts +++ b/packages/nocodb-nest/src/modules/test/TestResetService/resetMetaSakilaSqliteProject.ts @@ -1,11 +1,9 @@ import { promises as fs } from 'fs'; import axios from 'axios'; +import path from 'path' const sqliteFilePath = (parallelId: string) => { - const rootDir = __dirname.replace( - '/src/modules/test/TestResetService', - '', - ); + const rootDir = process.cwd() return `${rootDir}/test_sakila_${parallelId}.db`; }; @@ -78,10 +76,10 @@ const deleteSqliteFileIfExists = async (parallelId: string) => { }; const seedSakilaSqliteFile = async (parallelId: string) => { - const testsDir = __dirname.replace( - '/src/modules/test/TestResetService', - '/tests', - ); + const testsDir = path.join( + process.cwd(), + 'tests' + );; await fs.copyFile( `${testsDir}/sqlite-sakila-db/sakila.db`, diff --git a/packages/nocodb-nest/src/modules/test/TestResetService/resetMysqlSakilaProject.ts b/packages/nocodb-nest/src/modules/test/TestResetService/resetMysqlSakilaProject.ts index 6bcd3f1181..e4ed1121ab 100644 --- a/packages/nocodb-nest/src/modules/test/TestResetService/resetMysqlSakilaProject.ts +++ b/packages/nocodb-nest/src/modules/test/TestResetService/resetMysqlSakilaProject.ts @@ -1,4 +1,5 @@ import { promises as fs } from 'fs'; +import path from 'path'; import axios from 'axios'; import { knex } from 'knex'; import Audit from '../../../models/Audit'; @@ -85,10 +86,7 @@ const resetSakilaMysql = async ( parallelId: string, isEmptyProject: boolean, ) => { - const testsDir = __dirname.replace( - '/src/modules/test/TestResetService', - '/tests', - ); + const testsDir = path.join(process.cwd(), '/tests'); try { await knex.raw(`DROP DATABASE test_sakila_${parallelId}`); diff --git a/packages/nocodb-nest/src/modules/test/TestResetService/resetPgSakilaProject.ts b/packages/nocodb-nest/src/modules/test/TestResetService/resetPgSakilaProject.ts index 1a042c36d7..73923ef054 100644 --- a/packages/nocodb-nest/src/modules/test/TestResetService/resetPgSakilaProject.ts +++ b/packages/nocodb-nest/src/modules/test/TestResetService/resetPgSakilaProject.ts @@ -1,6 +1,7 @@ import { promises as fs } from 'fs'; import axios from 'axios'; import { knex } from 'knex'; +import path from 'path' import Audit from '../../../models/Audit'; import type Project from '../../../models/Project'; @@ -78,8 +79,8 @@ const isSakilaPgToBeReset = async (parallelId: string, project?: Project) => { }; const resetSakilaPg = async (parallelId: string, isEmptyProject: boolean) => { - const testsDir = __dirname.replace( - '/src/modules/test/TestResetService', + const testsDir = path.join( + process.cwd(), '/tests', );