diff --git a/tools/isobuild/compiler-plugin.js b/tools/isobuild/compiler-plugin.js index 207a21c026..454cdcdf08 100644 --- a/tools/isobuild/compiler-plugin.js +++ b/tools/isobuild/compiler-plugin.js @@ -384,10 +384,30 @@ class ResourceSlot { // contained by a node_modules directory will already have been // marked lazy in PackageSource#_inferFileOptions. Same for // non-test files if running unit tests (`meteor test-app --unit`) - return this.packageSourceBatch.useMeteorInstall && + if (!this.packageSourceBatch.useMeteorInstall) { + return false; + } + + const dirs = files.pathDirname(this.inputResource.path) - .split(files.pathSep) - .indexOf("imports") >= 0; + .split(files.pathSep); + + const isInImports = dirs.indexOf("imports") >= 0; + + if (global.testCommandMetadata && + (global.testCommandMetadata.isUnitTest || + global.testCommandMetadata.isIntegrationTest)) { + const isTestFile = _.any(dirs, (dir) => + /\.tests?\./.test(dir) || + /^tests?\./.test(dir) || + /^tests$/.test(dir)); + + // test files should always be included, if we're running app + // tests. + return isInImports && !isTestFile; + } else { + return isInImports; + } } addStylesheet(options) { diff --git a/tools/isobuild/package-source.js b/tools/isobuild/package-source.js index a7b6a7db72..9d2e283235 100644 --- a/tools/isobuild/package-source.js +++ b/tools/isobuild/package-source.js @@ -1344,7 +1344,7 @@ _.extend(PackageSource.prototype, { // If running in unit test mode (`meteor test-app --unit`), all // files other than test files should be loaded lazily - if (global.testCommandMetadata && testCommandMetadata.isUnitTest) { + if (global.testCommandMetadata && global.testCommandMetadata.isUnitTest) { const isTestFile = _.any(dirs, (dir) => /\.tests?\./.test(dir) || /^tests?\./.test(dir) ||