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

Migrate conditional tests to gate pragma #18585

Merged
merged 2 commits into from Apr 13, 2020

Conversation

acdlite
Copy link
Collaborator

@acdlite acdlite commented Apr 13, 2020

Based on #18582

I split this up from the previous PR because the changes in here weren't completely automated. I had to manually edit stuff.

I searched through the codebase for this pattern:

describe('test suite', () => {
  if (!__EXPERIMENTAL__) { // or some other condition
    test("empty test so Jest doesn't complain", () => {});
    return;
  }

  // Unless we're in experimental mode, none of the tests in this block
  // will run.
})

and converted them to the @gate pragma instead.

The reason this pattern isn't preferred is because you end up disabling more tests than you need to.

Quick review link

@facebook-github-bot facebook-github-bot added React Core Team Opened by a member of the React Core Team CLA Signed labels Apr 13, 2020
@codesandbox-ci
Copy link

codesandbox-ci bot commented Apr 13, 2020

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 8cbba9a:

Sandbox Source
objective-agnesi-mvlxu Configuration

@sizebot
Copy link

sizebot commented Apr 13, 2020

No significant bundle size changes to report.

Size changes (stable)

Generated by 🚫 dangerJS against a026682

@sizebot
Copy link

sizebot commented Apr 13, 2020

No significant bundle size changes to report.

Size changes (experimental)

Generated by 🚫 dangerJS against a026682

@acdlite acdlite marked this pull request as draft April 13, 2020 06:44
Copy link
Contributor

@bvaughn bvaughn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did not read closely. Scanned the diff and it seems okay.

TIL about it.each().

});

it('traces interaction across client-rendered hydration', async done => {
// @gate experimental
it('traces interaction across client-rendered hydration', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I don't think this test needs to be async.

@@ -599,7 +600,8 @@ describe('ReactDOMTracing', () => {
});

describe('hydration', () => {
it('traces interaction across hydration', async done => {
// @gate experimental
it('traces interaction across hydration', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I don't think this test needs to be async.

Using a heuristic where I check a flag that is known to only be enabled
in www. I left a TODO to instead set the release channel explicitly in
each test config.
I searched through the codebase for this pattern:

```js
describe('test suite', () => {
  if (!__EXPERIMENTAL__) { // or some other condition
    test("empty test so Jest doesn't complain", () => {});
    return;
  }

  // Unless we're in experimental mode, none of the tests in this block
  // will run.
})
```

and converted them to the `@gate` pragma instead.

The reason this pattern isn't preferred is because you end up disabling
more tests than you need to.
@acdlite acdlite force-pushed the migrate-conditional-tests branch 5 times, most recently from 2550b29 to 8cbba9a Compare April 13, 2020 21:26
@acdlite acdlite marked this pull request as ready for review April 13, 2020 21:45
@acdlite acdlite merged commit bec7599 into facebook:master Apr 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed React Core Team Opened by a member of the React Core Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants