From 226a62b52756183ece4f3959c4b601601d33a8d2 Mon Sep 17 00:00:00 2001 From: fatme Date: Wed, 10 Jul 2019 21:15:25 +0300 Subject: [PATCH] fix: fix the execution of unit tests with latest unit-test-runner and nativescript-dev-webpack@rc With the latest rc of nativescript-dev-webpack it is not possible to run unit tests as the nativescript-dev-webpack searches for app folder inside runner root folder. As such folder doesn't exist in live version of nativescript-unit-test-runner, test command throws an error. --- unit-testing-config-loader.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/unit-testing-config-loader.js b/unit-testing-config-loader.js index 981c3a4f..e3d4a2ff 100644 --- a/unit-testing-config-loader.js +++ b/unit-testing-config-loader.js @@ -1,10 +1,19 @@ const { join, relative } = require("path"); +const { existsSync } = require("fs"); const { convertSlashesInPath } = require("./projectHelpers"); +function getRunnerFullPath(projectRoot) { + const runnerRootPath = join(projectRoot, "node_modules", "nativescript-unit-test-runner"); + const runnerAppPath = join(runnerRootPath, "app"); + const result = existsSync(runnerAppPath) ? runnerAppPath : runnerRootPath; + + return result; +} + module.exports = function ({ appFullPath, projectRoot, angular, rootPagesRegExp }) { // TODO: Consider to use the files property from karma.conf.js const testFilesRegExp = /tests\/.*\.(ts|js)/; - const runnerFullPath = join(projectRoot, "node_modules", "nativescript-unit-test-runner", "app"); + const runnerFullPath = getRunnerFullPath(projectRoot); const runnerRelativePath = convertSlashesInPath(relative(appFullPath, runnerFullPath)); const appCssFilePath = convertSlashesInPath(join(runnerRelativePath, "app.css")); let source = `