woocommerce/tests/e2e/core-tests/core-tests-root.js

26 lines
777 B
JavaScript
Raw Normal View History

2021-03-25 14:59:00 +00:00
/**
* External dependencies
*/
const path = require( 'path' );
const getCoreTestsRoot = () => {
// Figure out where we're installed.
// Typically will be in node_modules/, but WooCommerce
2021-03-25 17:12:54 +00:00
// uses a local file path (tests/e2e/core-tests).
2021-03-25 14:59:00 +00:00
let coreTestsPath = false;
2021-03-25 17:12:54 +00:00
const moduleDir = path.dirname( require.resolve( '@woocommerce/e2e-core-tests' ) );
2021-03-25 14:59:00 +00:00
if ( -1 < moduleDir.indexOf( 'node_modules' ) ) {
coreTestsPath = moduleDir.split( 'node_modules' )[ 0 ];
2021-03-25 17:12:54 +00:00
} else if ( -1 < moduleDir.indexOf( 'tests/e2e/core-tests' ) ) {
coreTestsPath = moduleDir.split( 'tests/e2e/core-tests' )[ 0 ];
2021-03-25 14:59:00 +00:00
}
2021-03-25 17:12:54 +00:00
return {
appRoot: coreTestsPath,
packageRoot: moduleDir,
};
2021-03-25 14:59:00 +00:00
};
2021-03-25 17:12:54 +00:00
module.exports = getCoreTestsRoot;