Skip to content

Commit

Permalink
Run persistent tests in more configurations in CI (#21880)
Browse files Browse the repository at this point in the history
I noticed that `enableSuspenseLayoutEffectSemantics` is not fully
implemented in persistent mode. I believe this was an oversight
because we don't have a CI job that runs tests in persistent mode and
with experimental flags enabled.

This adds additional test configurations to the CI job so we don't miss
stuff like this again. It doesn't fix the failing tests — I'll address
that separately.
  • Loading branch information
acdlite authored Jul 14, 2021
1 parent 9090257 commit 8134676
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,7 @@ workflows:

# TODO: Test more persistent configurations?
- '-r=stable --env=development --persistent'
- '-r=experimental --env=development --persistent'
- yarn_build_combined:
requires:
- setup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ describe('ReactOffscreen', () => {

// @gate experimental || www
// @gate enableSuspenseLayoutEffectSemantics
// @gate !persistent
it('mounts/unmounts layout effects when visibility changes (starting visible)', async () => {
function Child({text}) {
useLayoutEffect(() => {
Expand Down Expand Up @@ -270,6 +271,7 @@ describe('ReactOffscreen', () => {

// @gate experimental || www
// @gate enableSuspenseLayoutEffectSemantics
// @gate !persistent
it('mounts/unmounts layout effects when visibility changes (starting hidden)', async () => {
function Child({text}) {
useLayoutEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ let caches;
let seededCache;
let ErrorBoundary;

// TODO: These tests don't pass in persistent mode yet. Need to implement.

describe('ReactSuspenseEffectsSemantics', () => {
beforeEach(() => {
jest.resetModules();
Expand Down Expand Up @@ -565,6 +567,7 @@ describe('ReactSuspenseEffectsSemantics', () => {

// @gate enableSuspenseLayoutEffectSemantics
// @gate enableCache
// @gate !persistent
it('should be destroyed and recreated for function components', async () => {
function App({children = null}) {
Scheduler.unstable_yieldValue('App render');
Expand Down Expand Up @@ -694,6 +697,7 @@ describe('ReactSuspenseEffectsSemantics', () => {

// @gate enableSuspenseLayoutEffectSemantics
// @gate enableCache
// @gate !persistent
it('should be destroyed and recreated for class components', async () => {
class ClassText extends React.Component {
componentDidMount() {
Expand Down Expand Up @@ -839,6 +843,7 @@ describe('ReactSuspenseEffectsSemantics', () => {

// @gate enableSuspenseLayoutEffectSemantics
// @gate enableCache
// @gate !persistent
it('should be destroyed and recreated when nested below host components', async () => {
function App({children = null}) {
Scheduler.unstable_yieldValue('App render');
Expand Down Expand Up @@ -949,6 +954,7 @@ describe('ReactSuspenseEffectsSemantics', () => {

// @gate enableSuspenseLayoutEffectSemantics
// @gate enableCache
// @gate !persistent
it('should be destroyed and recreated even if there is a bailout because of memoization', async () => {
const MemoizedText = React.memo(Text, () => true);

Expand Down Expand Up @@ -1065,6 +1071,7 @@ describe('ReactSuspenseEffectsSemantics', () => {

// @gate enableSuspenseLayoutEffectSemantics
// @gate enableCache
// @gate !persistent
it('should respect nested suspense boundaries', async () => {
function App({innerChildren = null, outerChildren = null}) {
return (
Expand Down Expand Up @@ -1288,6 +1295,7 @@ describe('ReactSuspenseEffectsSemantics', () => {

// @gate enableSuspenseLayoutEffectSemantics
// @gate enableCache
// @gate !persistent
it('should show nested host nodes if multiple boundaries resolve at the same time', async () => {
function App({innerChildren = null, outerChildren = null}) {
return (
Expand Down Expand Up @@ -1398,6 +1406,7 @@ describe('ReactSuspenseEffectsSemantics', () => {

// @gate enableSuspenseLayoutEffectSemantics
// @gate enableCache
// @gate !persistent
it('should be cleaned up inside of a fallback that suspends', async () => {
function App({fallbackChildren = null, outerChildren = null}) {
return (
Expand Down Expand Up @@ -1541,6 +1550,7 @@ describe('ReactSuspenseEffectsSemantics', () => {

// @gate enableSuspenseLayoutEffectSemantics
// @gate enableCache
// @gate !persistent
it('should be cleaned up inside of a fallback that suspends (alternate)', async () => {
function App({fallbackChildren = null, outerChildren = null}) {
return (
Expand Down Expand Up @@ -1661,6 +1671,7 @@ describe('ReactSuspenseEffectsSemantics', () => {

// @gate enableSuspenseLayoutEffectSemantics
// @gate enableCache
// @gate !persistent
it('should be cleaned up deeper inside of a subtree that suspends', async () => {
function ConditionalSuspense({shouldSuspend}) {
if (shouldSuspend) {
Expand Down Expand Up @@ -1744,6 +1755,7 @@ describe('ReactSuspenseEffectsSemantics', () => {
describe('that throw errors', () => {
// @gate enableSuspenseLayoutEffectSemantics
// @gate enableCache
// @gate !persistent
it('are properly handled for componentDidMount', async () => {
let componentDidMountShouldThrow = false;

Expand Down Expand Up @@ -1883,6 +1895,7 @@ describe('ReactSuspenseEffectsSemantics', () => {

// @gate enableSuspenseLayoutEffectSemantics
// @gate enableCache
// @gate !persistent
it('are properly handled for componentWillUnmount', async () => {
class ThrowsInWillUnmount extends React.Component {
componentDidMount() {
Expand Down Expand Up @@ -1996,6 +2009,7 @@ describe('ReactSuspenseEffectsSemantics', () => {

// @gate enableSuspenseLayoutEffectSemantics
// @gate enableCache
// @gate !persistent
// @gate replayFailedUnitOfWorkWithInvokeGuardedCallback
it('are properly handled for layout effect creation', async () => {
let useLayoutEffectShouldThrow = false;
Expand Down Expand Up @@ -2136,6 +2150,7 @@ describe('ReactSuspenseEffectsSemantics', () => {

// @gate enableSuspenseLayoutEffectSemantics
// @gate enableCache
// @gate !persistent
// @gate replayFailedUnitOfWorkWithInvokeGuardedCallback
it('are properly handled for layout effect descruction', async () => {
function ThrowsInLayoutEffectDestroy() {
Expand Down Expand Up @@ -2248,6 +2263,7 @@ describe('ReactSuspenseEffectsSemantics', () => {

// @gate enableSuspenseLayoutEffectSemantics
// @gate enableCache
// @gate !persistent
it('should be only destroy layout effects once if a tree suspends in multiple places', async () => {
class ClassText extends React.Component {
componentDidMount() {
Expand Down Expand Up @@ -2387,6 +2403,7 @@ describe('ReactSuspenseEffectsSemantics', () => {

// @gate enableSuspenseLayoutEffectSemantics
// @gate enableCache
// @gate !persistent
it('should be only destroy layout effects once if a component suspends multiple times', async () => {
class ClassText extends React.Component {
componentDidMount() {
Expand Down Expand Up @@ -2671,6 +2688,7 @@ describe('ReactSuspenseEffectsSemantics', () => {

// @gate enableSuspenseLayoutEffectSemantics
// @gate enableCache
// @gate !persistent
it('should be cleared and reset for host components', async () => {
function App({children}) {
Scheduler.unstable_yieldValue(`App render`);
Expand Down Expand Up @@ -2768,6 +2786,7 @@ describe('ReactSuspenseEffectsSemantics', () => {

// @gate enableSuspenseLayoutEffectSemantics
// @gate enableCache
// @gate !persistent
it('should be cleared and reset for class components', async () => {
class ClassComponent extends React.Component {
render() {
Expand Down Expand Up @@ -2869,6 +2888,7 @@ describe('ReactSuspenseEffectsSemantics', () => {

// @gate enableSuspenseLayoutEffectSemantics
// @gate enableCache
// @gate !persistent
it('should be cleared and reset for function components with useImperativeHandle', async () => {
const FunctionComponent = React.forwardRef((props, ref) => {
Scheduler.unstable_yieldValue('FunctionComponent render');
Expand Down Expand Up @@ -2974,6 +2994,7 @@ describe('ReactSuspenseEffectsSemantics', () => {

// @gate enableSuspenseLayoutEffectSemantics
// @gate enableCache
// @gate !persistent
it('should not reset for user-managed values', async () => {
function RefChecker({forwardedRef}) {
Scheduler.unstable_yieldValue(`RefChecker render`);
Expand Down Expand Up @@ -3072,6 +3093,7 @@ describe('ReactSuspenseEffectsSemantics', () => {
describe('that throw errors', () => {
// @gate enableSuspenseLayoutEffectSemantics
// @gate enableCache
// @gate !persistent
// @gate replayFailedUnitOfWorkWithInvokeGuardedCallback
it('are properly handled in ref callbacks', async () => {
let useRefCallbackShouldThrow = false;
Expand Down
2 changes: 2 additions & 0 deletions scripts/jest/TestFlags.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ const environmentFlags = {
// Similarly, should stable imply "classic"?
stable: !__EXPERIMENTAL__,

persistent: global.__PERSISTENT__ === true,

// Use this for tests that are known to be broken.
FIXME: false,

Expand Down

0 comments on commit 8134676

Please sign in to comment.