Skip to content

Commit 9c6bf82

Browse files
Fix unit tests on non-macOS (#2827)
Currently unit tests from master branch are failing on Windows and Linux. Fix them by applying the following: - Fix expected path in entitlements test - use `path.join` instead of hardcoded `/` - on Windows the path separator is `\` - Ignore tests for merging xcconfig files as they can work only on macOS, where ruby is installed. The tests will be ran only in case you are executing them on macOS. - Require "colors" module in test-bootstrap. During test execution I've noticed some "undefined" statements printed on the terminal. It turned out these are `logger.warn` statements. However the logic in the logger is to print `<message>.yellow`. When `colors` is not required, the strings do not have `yellow` property, so instead of seeing the real message, the loggger has been printing "undefined".
1 parent d3f06ab commit 9c6bf82

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

test/ios-entitlements-service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ describe("IOSEntitlements Service Tests", () => {
6060

6161
describe("Ensure paths constructed are correct", () => {
6262
it("Ensure destination entitlements relative path is calculated correctly.", () => {
63-
const expected = "testApp/testApp.entitlements";
63+
const expected = path.join("testApp", "testApp.entitlements");
6464
let actual = iOSEntitlementsService.getPlatformsEntitlementsRelativePath(projectData);
6565
assert.equal(actual, expected);
6666
});

test/ios-project-service.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,10 @@ describe("iOS Project Service Signing", () => {
751751
});
752752

753753
describe("Merge Project XCConfig files", () => {
754+
if (require("os").platform() !== "darwin") {
755+
console.log("Skipping 'Merge Project XCConfig files' tests. They can work only on macOS");
756+
return;
757+
}
754758
const assertPropertyValues = (expected: any, xcconfigPath: string, injector: IInjector) => {
755759
let service = <XCConfigService>injector.resolve('xCConfigService');
756760
_.forOwn(expected, (value, key) => {
@@ -782,7 +786,7 @@ describe("Merge Project XCConfig files", () => {
782786

783787
appResourcesXcconfigPath = path.join(projectData.projectDir, constants.APP_FOLDER_NAME,
784788
constants.APP_RESOURCES_FOLDER_NAME, "iOS", "build.xcconfig");
785-
appResourceXCConfigContent = `CODE_SIGN_IDENTITY = iPhone Distribution
789+
appResourceXCConfigContent = `CODE_SIGN_IDENTITY = iPhone Distribution
786790
// To build for device with XCode 8 you need to specify your development team. More info: https://developer.apple.com/library/prerelease/content/releasenotes/DeveloperTools/RN-Xcode/Introduction.html
787791
// DEVELOPMENT_TEAM = YOUR_TEAM_ID;
788792
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;

test/test-bootstrap.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,16 @@ const cliGlobal = <ICliGlobal>global;
99
cliGlobal._ = require("lodash");
1010
cliGlobal.$injector = require("../lib/common/yok").injector;
1111

12+
// Requiring colors will modify the prototype of String
13+
// We need it as in some places we use <string>.<color>, which is undefined when colors is not required
14+
// So we sometimes miss warnings in the tests as we receive "undefined".
15+
require("colors");
16+
1217
use(require("chai-as-promised"));
1318

1419
$injector.register("analyticsService", {
15-
trackException: (): { wait(): void } => {
16-
return {
17-
wait: () => undefined
18-
};
20+
trackException: async (exception: any, message: string): Promise<void> => {
21+
// Intentionally left blank.
1922
}
2023
});
2124

0 commit comments

Comments
 (0)