Skip to content

Commit

Permalink
Relay: More Resilient cannotReadPropertyOfUndefined
Browse files Browse the repository at this point in the history
Summary: Revises `cannotReadPropertyOfUndefined__DEPRECATED` in the Relay test suite to be resilient to future Node.js version upgrades, beyond v16.

Reviewed By: josephsavona

Differential Revision: D45432790

fbshipit-source-id: 1a656e73a998cc76deb47635e8cea264205bce53
  • Loading branch information
yungsters authored and facebook-github-bot committed May 1, 2023
1 parent fd06faa commit f5c48cd
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/relay-test-utils-internal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,12 @@ const {createMockEnvironment, unwrapContainer} = require('relay-test-utils');
function cannotReadPropertyOfUndefined__DEPRECATED(
propertyName: string,
): string {
if (process.version.match(/^v16\.(.+)$/)) {
return `Cannot read properties of undefined (reading '${propertyName}')`;
} else {
const matches = process.version.match(/^v(\d+)\./);
const majorVersion = matches == null ? null : parseInt(matches[0], 10);
if (majorVersion == null || majorVersion < 16) {
return `Cannot read property '${propertyName}' of undefined`;
}
return `Cannot read properties of undefined (reading '${propertyName}')`;
}

/**
Expand Down

0 comments on commit f5c48cd

Please sign in to comment.