Skip to content

Commit

Permalink
fix: gracefully handle missing test cases between two apps
Browse files Browse the repository at this point in the history
  • Loading branch information
kirillzyusko committed Apr 22, 2024
1 parent 9b2c518 commit 898bd17
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/libs/E2E/reactNativeLaunchingTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ E2EClient.getTestConfig()
console.error(`[E2E] Test '${config.name}' not found`);
// instead of throwing, report the error to the server, which is better for DX
return E2EClient.submitTestResults({
branch: Config.E2E_BRANCH,
name: config.name,
error: `Test '${config.name}' not found`,
isCritical: false,
Expand Down
12 changes: 9 additions & 3 deletions tests/e2e/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type ServerInstance = {
addTestStartedListener: AddListener<TestStartedListener>;
addTestResultListener: AddListener<TestResultListener>;
addTestDoneListener: AddListener<TestDoneListener>;
forceTestCompletion: () => void;
start: () => Promise<void>;
stop: () => Promise<Error | undefined>;
};
Expand Down Expand Up @@ -96,6 +97,12 @@ const createServerInstance = (): ServerInstance => {
const [testResultListeners, addTestResultListener] = createListenerState<TestResultListener>();
const [testDoneListeners, addTestDoneListener] = createListenerState<TestDoneListener>();

const forceTestCompletion = () => {
testDoneListeners.forEach((listener) => {
listener();
});
};

let activeTestConfig: TestConfig | undefined;
const networkCache: Record<string, NetworkCacheMap> = {};

Expand Down Expand Up @@ -131,9 +138,7 @@ const createServerInstance = (): ServerInstance => {
}

case Routes.testDone: {
testDoneListeners.forEach((listener) => {
listener();
});
forceTestCompletion();
return res.end('ok');
}

Expand Down Expand Up @@ -200,6 +205,7 @@ const createServerInstance = (): ServerInstance => {
addTestStartedListener,
addTestResultListener,
addTestDoneListener,
forceTestCompletion,
start: () =>
new Promise<void>((resolve) => {
server.listen(PORT, resolve);
Expand Down
2 changes: 2 additions & 0 deletions tests/e2e/testRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ const runTests = async (): Promise<void> => {
throw new Error(`Test '${testResult.name}' failed with error: ${testResult.error}`);
}
if (testResult?.error != null && !isCritical) {
// force test completion, since we don't want to have timeout error for non being execute test
server.forceTestCompletion();
Logger.warn(`Test '${testResult.name}' failed with error: ${testResult.error}`);
}
let result = 0;
Expand Down

0 comments on commit 898bd17

Please sign in to comment.