Normalize newlines in public-api-test (#45145)

Summary:
Tests were failing on windows due to parsing CRLF line endings. This change enables the API tests for windows by normalizing line endings before parsing the file.

## Changelog:
[INTERNAL] [ADDED] - `public-api-test` now runs on Windows.

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests

Pull Request resolved: https://github.com/facebook/react-native/pull/45145

Test Plan: Build-time-only change; relying on CircleCI

Reviewed By: cipolleschi

Differential Revision: D59001867

Pulled By: huntie

fbshipit-source-id: a7a41945e8c93288be1d5b7b59df7f621e467657
This commit is contained in:
Leon Xu
2024-06-26 10:42:47 -07:00
committed by Facebook GitHub Bot
parent 2c210939d3
commit 873ebc8055
@@ -66,14 +66,6 @@ const sourceFiles = [
];
describe('public API', () => {
if (os.platform() === 'win32') {
// TODO(huntie): Re-enable once upstream flow-api-translator fixes are made
// eslint-disable-next-line jest/no-focused-tests
test.only('skipping tests on win32', () => {
console.log('skipping tests');
});
}
describe('should not change unintentionally', () => {
test.each(sourceFiles)('%s', async (file: string) => {
const source = await fs.readFile(path.join(PACKAGE_ROOT, file), 'utf-8');
@@ -111,6 +103,8 @@ describe('public API', () => {
});
async function translateFlowToExportedAPI(source: string): Promise<string> {
// Normalize newlines
source = source.replace(/\r\n?/g, '\n');
// Convert to Flow typedefs
const typeDefSource = await translate.translateFlowToFlowDef(source);