Skip to content

Commit

Permalink
Fix test_build_devtools CI job to run test-build-devtools (#17631)
Browse files Browse the repository at this point in the history
* Skip abandoned project folders in Jest config

This fixes a problem that occurs after renaming a package.

* Fix test_build_devtools to run test-build-devtools

* Exclude console.error plugin for DevTools packages

* Use correct release channel for DevTools tests

This should fix the createRoot error.

* Fix TZ dependent test

* Change DT job dependencies
  • Loading branch information
gaearon authored and Brian Vaughn committed Dec 17, 2019
1 parent 7c21bf7 commit 36a6e29
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 14 deletions.
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,8 @@ jobs:
- *run_yarn
- run:
environment:
RELEASE_CHANNEL: stable
command: yarn test-build --maxWorkers=2
RELEASE_CHANNEL: experimental
command: yarn test-build-devtools --maxWorkers=2

test_dom_fixtures:
docker: *docker
Expand Down Expand Up @@ -376,7 +376,7 @@ workflows:
- build
- test_build_devtools:
requires:
- build
- build_experimental
- test_dom_fixtures:
requires:
- build
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,7 @@ describe('InspectedElementContext', () => {
const arrayOfArrays = [[['abc', 123, true], []]];
const div = document.createElement('div');
const exampleFunction = () => {};
const exampleDateISO = '2019-12-31T23:42:42.000Z';
const setShallow = new Set(['abc', 123]);
const mapShallow = new Map([['name', 'Brian'], ['food', 'sushi']]);
const setOfSets = new Set([new Set(['a', 'b', 'c']), new Set([1, 2, 3])]);
Expand Down Expand Up @@ -542,7 +543,7 @@ describe('InspectedElementContext', () => {
// eslint-disable-next-line no-undef
big_int={BigInt(123)}
data_view={dataView}
date={new Date(123)}
date={new Date(exampleDateISO)}
fn={exampleFunction}
html_element={div}
immutable={immutableMap}
Expand Down Expand Up @@ -634,11 +635,11 @@ describe('InspectedElementContext', () => {

expect(date[meta.inspectable]).toBe(false);
expect(date[meta.type]).toBe('date');
expect(date[meta.preview_long]).toBe(
'Wed Dec 31 1969 16:00:00 GMT-0800 (Pacific Standard Time)',
expect(new Date(date[meta.preview_long]).toISOString()).toBe(
exampleDateISO,
);
expect(date[meta.preview_short]).toBe(
'Wed Dec 31 1969 16:00:00 GMT-0800 (Pacific Standard Time)',
expect(new Date(date[meta.preview_short]).toISOString()).toBe(
exampleDateISO,
);

expect(fn[meta.inspectable]).toBe(false);
Expand Down
8 changes: 7 additions & 1 deletion scripts/jest/config.build-devtools.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ const packages = readdirSync(packagesRoot).filter(dir => {
return false;
}
const packagePath = join(packagesRoot, dir, 'package.json');
return statSync(packagePath).isFile();
let stat;
try {
stat = statSync(packagePath);
} catch (err) {
return false;
}
return stat.isFile();
});

// Create a module map to point React packages to the build output
Expand Down
8 changes: 7 additions & 1 deletion scripts/jest/config.build.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ const packages = readdirSync(packagesRoot).filter(dir => {
return false;
}
const packagePath = join(packagesRoot, dir, 'package.json');
return statSync(packagePath).isFile();
let stat;
try {
stat = statSync(packagePath);
} catch (err) {
return false;
}
return stat.isFile();
});

// Create a module map to point React packages to the build output
Expand Down
11 changes: 7 additions & 4 deletions scripts/jest/preprocessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,14 @@ module.exports = {
// for test files, we also apply the async-await transform, but we want to
// make sure we don't accidentally apply that transform to product code.
const isTestFile = !!filePath.match(/\/__tests__\//);
const isInDevToolsPackages = !!filePath.match(
/\/packages\/react-devtools.*\//
);
const testOnlyPlugins = [pathToBabelPluginAsyncToGenerator];
const sourceOnlyPlugins =
process.env.NODE_ENV === 'development'
? [pathToBabelPluginReplaceConsoleCalls]
: [];
const sourceOnlyPlugins = [];
if (process.env.NODE_ENV === 'development' && !isInDevToolsPackages) {
sourceOnlyPlugins.push(pathToBabelPluginReplaceConsoleCalls);
}
const plugins = (isTestFile ? testOnlyPlugins : sourceOnlyPlugins).concat(
babelOptions.plugins
);
Expand Down

0 comments on commit 36a6e29

Please sign in to comment.