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

fix[ci]: fixed jest configuration not to skip too many devtools tests #26955

Merged
Merged
Show file tree
Hide file tree
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
Expand Up @@ -938,7 +938,8 @@ describe('ProfilingCache', () => {
}
});

// @reactVersion = 17.0
// @reactVersion >= 17
// @reactVersion < 18
it('should handle unexpectedly shallow suspense trees', () => {
// This test only runs in v17 because it's a regression test for legacy
// Suspense behavior, and the implementation details changed in v18.
Expand Down Expand Up @@ -967,7 +968,15 @@ describe('ProfilingCache', () => {
"passiveEffectDuration": null,
"priorityLevel": "Normal",
"timestamp": 0,
"updaters": null,
"updaters": [
{
"displayName": "render()",
"hocDisplayNames": null,
"id": 1,
"key": null,
"type": 11,
},
],
},
]
`);
Expand Down
Expand Up @@ -10,7 +10,6 @@ const semver = require('semver');

let shouldPass;
let isFocused;
let shouldIgnore;
describe('transform-react-version-pragma', () => {
const originalTest = test;

Expand All @@ -34,7 +33,6 @@ describe('transform-react-version-pragma', () => {
// eslint-disable-next-line no-unused-vars
const _test_ignore_for_react_version = (testName, cb) => {
originalTest(testName, (...args) => {
shouldIgnore = true;
shouldPass = false;
return cb(...args);
});
Expand All @@ -43,7 +41,6 @@ describe('transform-react-version-pragma', () => {
beforeEach(() => {
shouldPass = null;
isFocused = false;
shouldIgnore = false;
});

// @reactVersion >= 17.9
Expand Down Expand Up @@ -137,14 +134,4 @@ describe('transform-react-version-pragma', () => {
expect(shouldPass).toBe(true);
expect(isFocused).toBe(true);
});

test('ignore test if no reactVersion', () => {
expect(shouldPass).toBe(false);
expect(shouldIgnore).toBe(true);
});

test.only('ignore focused test if no reactVersion', () => {
expect(shouldPass).toBe(false);
expect(shouldIgnore).toBe(true);
});
});
5 changes: 3 additions & 2 deletions scripts/babel/transform-react-version-pragma.js
Expand Up @@ -5,6 +5,7 @@
const getComments = require('./getComments');

const GATE_VERSION_STR = '@reactVersion ';
const REACT_VERSION_ENV = process.env.REACT_VERSION;

function transform(babel) {
const {types: t} = babel;
Expand Down Expand Up @@ -75,7 +76,7 @@ function transform(babel) {
? '_test_react_version_focus'
: '_test_react_version';
expression.arguments = [condition, ...expression.arguments];
} else {
} else if (REACT_VERSION_ENV) {
callee.name = '_test_ignore_for_react_version';
}
}
Expand All @@ -96,7 +97,7 @@ function transform(babel) {
t.identifier('_test_react_version_focus'),
[condition, ...expression.arguments]
);
} else {
} else if (REACT_VERSION_ENV) {
statement.expression = t.callExpression(
t.identifier('_test_ignore_for_react_version'),
expression.arguments
Expand Down
6 changes: 3 additions & 3 deletions scripts/jest/devtools/setupEnv.js
@@ -1,7 +1,7 @@
'use strict';

const semver = require('semver');
const ReactVersion = require('../../../packages/shared/ReactVersion');
const {ReactVersion} = require('../../../ReactVersions');

const {
DARK_MODE_DIMMED_WARNING_COLOR,
Expand Down Expand Up @@ -32,7 +32,7 @@ global.process.env.LIGHT_MODE_DIMMED_ERROR_COLOR =
global.process.env.LIGHT_MODE_DIMMED_LOG_COLOR = LIGHT_MODE_DIMMED_LOG_COLOR;

global._test_react_version = (range, testName, callback) => {
const reactVersion = process.env.REACT_VERSION || ReactVersion.default;
const reactVersion = process.env.REACT_VERSION || ReactVersion;
const shouldPass = semver.satisfies(reactVersion, range);

if (shouldPass) {
Expand All @@ -43,7 +43,7 @@ global._test_react_version = (range, testName, callback) => {
};

global._test_react_version_focus = (range, testName, callback) => {
const reactVersion = process.env.REACT_VERSION || ReactVersion.default;
const reactVersion = process.env.REACT_VERSION || ReactVersion;
const shouldPass = semver.satisfies(reactVersion, range);

if (shouldPass) {
Expand Down
12 changes: 3 additions & 9 deletions scripts/jest/jest-cli.js
Expand Up @@ -16,8 +16,6 @@ const devToolsConfig = './scripts/jest/config.build-devtools.js';
const persistentConfig = './scripts/jest/config.source-persistent.js';
const buildConfig = './scripts/jest/config.build.js';

const {ReactVersion} = require('../../ReactVersions');

const argv = yargs
.parserConfiguration({
// Important: This option tells yargs to move all other options not
Expand Down Expand Up @@ -181,13 +179,9 @@ function validateOptions() {
success = false;
}

if (argv.reactVersion) {
if (!semver.validRange(argv.reactVersion)) {
success = false;
logError('please specify a valid version range for --reactVersion');
}
} else {
argv.reactVersion = ReactVersion;
if (argv.reactVersion && !semver.validRange(argv.reactVersion)) {
success = false;
logError('please specify a valid version range for --reactVersion');
}
} else {
if (argv.compactConsole) {
Expand Down
7 changes: 1 addition & 6 deletions scripts/jest/preprocessor.js
Expand Up @@ -86,12 +86,7 @@ module.exports = {
const plugins = (isTestFile ? testOnlyPlugins : sourceOnlyPlugins).concat(
babelOptions.plugins
);
if (
isTestFile &&
isInDevToolsPackages &&
(process.env.REACT_VERSION ||
filePath.match(/\/transform-react-version-pragma-test/))
) {
if (isTestFile && isInDevToolsPackages) {
plugins.push(pathToTransformReactVersionPragma);
}
let sourceAst = hermesParser.parse(src, {babel: true});
Expand Down