Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"@electron/packager": "^20.0.0",
"@expo/spawn-async": "^1.7.2",
"@jest/create-cache-key-function": "^29.7.0",
"@jest/test-sequencer": "^29.7.0",
"@microsoft/api-extractor": "^7.52.2",
"@octokit/rest": "^22.0.0",
"@react-native/metro-babel-transformer": "0.87.0-main",
Expand Down
24 changes: 24 additions & 0 deletions private/react-native-fantom/config/FantomTestSequencer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @noflow
* @format
*/

'use strict';

const prepareFantomTestResultsForCache = require('./prepareFantomTestResultsForCache');
const TestSequencer = require('@jest/test-sequencer').default;

class FantomTestSequencer extends TestSequencer {
cacheResults(tests, results) {
// Jest 29 treats suite-level runtime errors as passing in its retry cache
// because they have no failed test cases (https://github.com/jestjs/jest/issues/15382).
super.cacheResults(tests, prepareFantomTestResultsForCache(results));
}
}

module.exports = FantomTestSequencer;
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @format
*/

'use strict';

const prepareFantomTestResultsForCache = require('../prepareFantomTestResultsForCache');

describe('prepareFantomTestResultsForCache', () => {
it('marks suite-level runtime errors as failed for Jest retries', () => {
const runtimeFailure = {
numFailingTests: 0,
testExecError: new Error('Process exited with SIGSEGV'),
};
const passingResult = {numFailingTests: 0};
const assertionFailure = {numFailingTests: 1};
const results = {
testResults: [runtimeFailure, passingResult, assertionFailure],
};

const cacheResults = prepareFantomTestResultsForCache(results);

expect(cacheResults.testResults).toEqual([
{...runtimeFailure, numFailingTests: 1},
passingResult,
assertionFailure,
]);
expect(results.testResults[0]).toBe(runtimeFailure);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @format
*/

'use strict';

/*::
type FantomTestResult = {
readonly numFailingTests: number,
readonly testExecError?: ?unknown,
...,
};

type FantomAggregatedResult = {
readonly testResults: ReadonlyArray<FantomTestResult>,
...,
};
*/

function prepareFantomTestResultsForCache(
results /*: FantomAggregatedResult */,
) /*: FantomAggregatedResult */ {
return {
...results,
testResults: results.testResults.map(testResult =>
testResult.testExecError != null && testResult.numFailingTests === 0
? {...testResult, numFailingTests: 1}
: testResult,
),
};
}

module.exports = prepareFantomTestResultsForCache;
5 changes: 4 additions & 1 deletion scripts/fantom.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,7 @@ if [[ -n "$FANTOM_RUN_BENCHMARKS" ]]; then
ARGS+=("--runInBand")
fi

yarn jest --config private/react-native-fantom/config/jest.config.js "${ARGS[@]}"
yarn jest \
--config private/react-native-fantom/config/jest.config.js \
--testSequencer '<rootDir>/private/react-native-fantom/config/FantomTestSequencer.js' \
"${ARGS[@]}"
Loading