2020-07-24 13:12:07 +00:00
|
|
|
const path = require( 'path' );
|
|
|
|
const fs = require( 'fs' );
|
2020-07-29 21:57:59 +00:00
|
|
|
const getAppRoot = require( './app-root' );
|
|
|
|
|
|
|
|
// Copy local test configuration file if it exists.
|
|
|
|
const appPath = getAppRoot();
|
|
|
|
const localTestConfigFile = path.resolve( appPath, 'tests/e2e/config/default.json' );
|
|
|
|
const testConfigFile = path.resolve( __dirname, '../config/default.json' );
|
|
|
|
if ( fs.existsSync( localTestConfigFile ) ) {
|
|
|
|
fs.copyFileSync(
|
|
|
|
localTestConfigFile,
|
|
|
|
testConfigFile
|
|
|
|
);
|
|
|
|
}
|
2020-07-24 13:12:07 +00:00
|
|
|
|
|
|
|
const getTestConfig = () => {
|
|
|
|
const rawTestConfig = fs.readFileSync( testConfigFile );
|
|
|
|
|
|
|
|
let testConfig = JSON.parse(rawTestConfig);
|
|
|
|
testConfig.baseUrl = testConfig.url.substr(0, testConfig.url.length - 1);
|
|
|
|
let testPort = testConfig.url.match(/[0-9]+/);
|
|
|
|
testConfig.port = testPort[0] ? testPort[0] : '8084';
|
|
|
|
return testConfig;
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = getTestConfig;
|