I have written a short test that fetches login credentials from a local file using the fs-module and logs in.
Code:
describe("loginAndNavigate", function() {
const fs = require('fs');
// Reading the JSON config file and converting it to a JS object
let configData = fs.readFileSync("C:\\Users\\JohnDoe\\SenchaTest\\Tests\\database_integration\\test\\basic_stuff\\lib\\config.json");
configData = JSON.parse(configData);
....
This works perfectly fine, but as soon as I want to use the relative path (see below for every notation I tried) the following error occurs.
[ERROR] [model/browser/SandboxBrowser-14] [ERROR] [orion] Error: ENOENT: no such file or directory, open 'C:\Program Files\Sencha\Test\2_2_1_83\test\basic_stuff\lib\config.json' at Error (native) at Object.fs.openSync (fs.js:640:18) at Object.module.(anonymous function) [as openSync] (ELECTRON_ASAR.js:173:20) at Object.fs.readFileSync (fs.js:508:33) at Object.fs.readFileSync (ELECTRON_ASAR.js:506:29) at Suite.<anonymous>
(C:\Users\JohnDoe\SenchaTest\Tests\database_integration\test\basic_stuff\loginAndNavigate.js:5:22) at addSpecsToSuite (C:\Program Files\Sencha\Test\2_2_1_83\resources\app.asar\node_modules\orion-core\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:864:25) at Env.describe (C:\Program Files\Sencha\Test\2_2_1_83\resources\app.asar\node_modules\orion-core\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:833:7) at doDescribe (C:\Program Files\Sencha\Test\2_2_1_83\resources\app.asar\node_modules\orion-core\serve\jasmine-post-extensions.js:52:26) at Object.fn (C:\Program Files\Sencha\Test\2_2_1_83\resources\app.asar\node_modules\orion-core\serve\jasmine-post-extensions.js:90:20)
For every one of these lines (of course not all of them at once)
Code:
let configData = fs.readFileSync("test\\basic_stuff\\lib\\config.json");
let configData = fs.readFileSync("test/basic_stuff/lib/config.json");
let configData = fs.readFileSync("./test/basic_stuff/lib/config.json");
Note that every one of these commands work a regular js file located in the same folder as my test spec.