From a54ba7431d2c79a9629f91f0c37c447a546424b5 Mon Sep 17 00:00:00 2001 From: fatme Date: Mon, 14 Oct 2019 08:58:33 +0300 Subject: [PATCH] fix: pass appPath to the env from karma.conf.js Two different webpack compilations are started on `tns test` command - the one from `karma-webpack` and the second one from `nativescript-dev-webpack`. As the karma's webpack doesn't provide appPath to the env and there is a hardcoded `appPath` inside `webpack.config.js` (to `src` for example), it works only with that hardcoded path. Rel to: https://github.com/NativeScript/nativescript-cli/issues/5070 --- lib/services/test-execution-service.ts | 2 ++ resources/test/karma.conf.js | 1 + 2 files changed, 3 insertions(+) diff --git a/lib/services/test-execution-service.ts b/lib/services/test-execution-service.ts index f62daba04f..d16da4b885 100644 --- a/lib/services/test-execution-service.ts +++ b/lib/services/test-execution-service.ts @@ -6,6 +6,7 @@ import { RunController } from "../controllers/run-controller"; interface IKarmaConfigOptions { debugBrk: boolean; debugTransport: boolean; + appPath: string; } export class TestExecutionService implements ITestExecutionService { @@ -156,6 +157,7 @@ export class TestExecutionService implements ITestExecutionService { karmaConfig.projectDir = projectData.projectDir; karmaConfig.bundle = true; karmaConfig.debugBrk = this.$options.debugBrk; + karmaConfig.appPath = projectData.getAppDirectoryRelativePath(); karmaConfig.platform = platform.toLowerCase(); this.$logger.debug(JSON.stringify(karmaConfig, null, 4)); diff --git a/resources/test/karma.conf.js b/resources/test/karma.conf.js index e646ebb976..3b96bbbc9f 100644 --- a/resources/test/karma.conf.js +++ b/resources/test/karma.conf.js @@ -99,6 +99,7 @@ function setWebpack(config, options) { const env = {}; env[config.platform] = true; env.sourceMap = config.debugBrk; + env.appPath = config.appPath; options.webpack = require('./webpack.config')(env); delete options.webpack.entry; delete options.webpack.output.libraryTarget;