Added core tests root and updated test

This commit is contained in:
Veljko 2021-03-25 15:59:00 +01:00
parent dcee9ce109
commit afd39e5866
2 changed files with 27 additions and 2 deletions

View File

@ -0,0 +1,22 @@
/**
* External dependencies
*/
const path = require( 'path' );
const getCoreTestsRoot = () => {
// Figure out where we're installed.
// Typically will be in node_modules/, but WooCommerce
// uses a local file path (tests/e2e/env).
let coreTestsPath = false;
const moduleDir = path.dirname( require.resolve( '@woocommerce/e2e-environment' ) );
if ( -1 < moduleDir.indexOf( 'node_modules' ) ) {
coreTestsPath = moduleDir.split( 'node_modules' )[ 0 ];
} else if ( -1 < moduleDir.indexOf( 'tests/e2e/env' ) ) {
coreTestsPath = moduleDir.split( 'tests/e2e/env' )[ 0 ];
}
return coreTestsPath;
};
module.exports = getCoreTestsRoot;

View File

@ -7,6 +7,7 @@
setCheckbox,
moveAllItemsToTrash
} = require( '@woocommerce/e2e-utils' );
const getCoreTestsRoot = require( '../../core-tests-root' );
/**
* External dependencies
@ -16,8 +17,10 @@ const {
describe
} = require( '@jest/globals' );
const filePath = '../../../sample-data/sample_products.csv';
const filePathOverride = '../../../tests/e2e/core-tests/test-data/sample_products_override.csv';
const path = require( 'path' );
const coreTestsPath = getCoreTestsRoot();
const filePath = path.resolve( coreTestsPath, 'sample-data/sample_products.csv' );
const filePathOverride = path.resolve( coreTestsPath, 'tests/e2e/core-tests/test-data/sample_products_override.csv' );
const productNames = ["V-Neck T-Shirt", "Hoodie", "Hoodie with Logo", "T-Shirt", "Beanie",
"Belt", "Cap", "Sunglasses", "Hoodie with Pocket", "Hoodie with Zipper", "Long Sleeve Tee", "Polo", "Album",
"Single", "T-Shirt with Logo", "Beanie with Logo", "Logo Collection", "WordPress Pennant"];