core/tests/Drupal/Nightwatch/nightwatch.conf.js | 33 +++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/core/tests/Drupal/Nightwatch/nightwatch.conf.js b/core/tests/Drupal/Nightwatch/nightwatch.conf.js index cea7052364..a7f069d432 100644 --- a/core/tests/Drupal/Nightwatch/nightwatch.conf.js +++ b/core/tests/Drupal/Nightwatch/nightwatch.conf.js @@ -12,6 +12,39 @@ const collectedFolders = { const searchDirectory = process.env.DRUPAL_NIGHTWATCH_SEARCH_DIRECTORY || ''; const defaultIgnore = ['vendor/**']; +// Find test infrastructure provided by Drupal. +glob + .sync('**/tests/**/Nightwatch/**/*.js', { + cwd: path.resolve(process.cwd()), + ignore: process.env.DRUPAL_NIGHTWATCH_IGNORE_DIRECTORIES + ? process.env.DRUPAL_NIGHTWATCH_IGNORE_DIRECTORIES.split(',').concat( + defaultIgnore, + ) + : defaultIgnore, + }) + .forEach((file) => { + let m = regex.exec(file); + while (m !== null) { + // This is necessary to avoid infinite loops with zero-width matches. + if (m.index === regex.lastIndex) { + regex.lastIndex += 1; + } + + const moduleDirectory = m[1]; + Object.keys(collectedFolders).forEach((folder) => { + // Finding tests happens in the next glob. + if (folder === 'Tests') { + return; + } + if (file.includes(`Nightwatch/${folder}`)) { + collectedFolders[folder].push(`../${searchDirectory}/${moduleDirectory}/${folder}`); + } + }); + m = regex.exec(file); + } + }); + +// Find the tests in DRUPAL_NIGHTWATCH_SEARCH_DIRECTORY. glob .sync('**/tests/**/Nightwatch/**/*.js', { cwd: path.resolve(process.cwd(), `../${searchDirectory}`),