Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DevTools] Add jest-cli --reactVersion argument #24556

Merged
merged 1 commit into from May 16, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 19 additions & 0 deletions scripts/jest/jest-cli.js
Expand Up @@ -5,6 +5,7 @@ const chalk = require('chalk');
const yargs = require('yargs');
const fs = require('fs');
const path = require('path');
const semver = require('semver');

const ossConfig = './scripts/jest/config.source.js';
const wwwConfig = './scripts/jest/config.source-www.js';
Expand Down Expand Up @@ -104,6 +105,11 @@ const argv = yargs
type: 'boolean',
default: false,
},
reactVersion: {
describe: 'DevTools testing for specific version of React',
requiresArg: true,
type: 'string',
},
}).argv;

function logError(message) {
Expand Down Expand Up @@ -166,11 +172,20 @@ function validateOptions() {
logError('DevTool tests require --build.');
success = false;
}

if (argv.reactVersion && !semver.validRange(argv.reactVersion)) {
success = false;
logError('please specify a valid version range for --reactVersion');
}
} else {
if (argv.compactConsole) {
logError('Only DevTool tests support compactConsole flag.');
success = false;
}
if (argv.reactVersion) {
logError('Only DevTools tests supports the --reactVersion flag.');
success = false;
}
}

if (isWWWConfig()) {
Expand Down Expand Up @@ -314,6 +329,10 @@ function getEnvars() {
envars.VARIANT = true;
}

if (argv.reactVersion) {
envars.REACT_VERSION = semver.coerce(argv.reactVersion);
}

return envars;
}

Expand Down