Skip to content
This repository was archived by the owner on Aug 7, 2021. It is now read-only.

Commit a216ed3

Browse files
Fatmerosen-vladimirov
authored andcommitted
fix: inject app.css file from unit-test-runner on test command (#949)
Currently the app.css file from unit-test-runner is not included in bundle/vendor files on test command so the application remains without app.css file. The `tns-core-modules` shows an error in this situation with the in their latest next versions: ``` JS: Error: Could not load CSS from ./app.css: Error: com.tns.NativeScriptException: Failed to find module: "./app.css", relative to: app// JS: com.tns.Module.resolvePathHelper(Module.java:146) JS: com.tns.Module.resolvePath(Module.java:55) JS: com.tns.Runtime.callJSMethodNative(Native Method) JS: com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1212) JS: com.tns.Runtime.callJSMethodImpl(Runtime.java:1092) JS: com.tns.Runtime.callJSMethod(Runtime.java:1079) JS: com.tns.Runtime.callJSMethod(Runtime.java:1059) JS: com.tns.Runtime.callJSMethod(Runtime.java:1051) JS: com.tns.NativeScriptActivity.onCreate(NativeScriptActivity.java:19) JS: android.app.Activity.performCreate(Activity.java:7136) JS: android.app.Activity.performCreate(Activity.java:7127) JS: android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271) JS: android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893) JS: android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048) JS: android.app.servertransac... ``` So we need to inject app.css in order to prevent this error :)
1 parent 1e42046 commit a216ed3

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

Diff for: unit-testing-config-loader.js

+3
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@ module.exports = function ({ appFullPath, projectRoot, angular, rootPagesRegExp
66
const testFilesRegExp = /tests\/.*\.(ts|js)/;
77
const runnerFullPath = join(projectRoot, "node_modules", "nativescript-unit-test-runner");
88
const runnerRelativePath = convertSlashesInPath(relative(appFullPath, runnerFullPath));
9+
const appCssFilePath = join(runnerRelativePath, "app.css");
910
let source = `
1011
require("tns-core-modules/bundle-entry-points");
1112
const runnerContext = require.context("${runnerRelativePath}", true, ${rootPagesRegExp});
1213
global.registerWebpackModules(runnerContext);
14+
global.registerModule("${appCssFilePath}", () => require("${appCssFilePath}"));
15+
require("tns-core-modules/application").setCssFileName("${appCssFilePath}");
1316
`;
1417

1518
if (angular) {

0 commit comments

Comments
 (0)