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

Run Jest in production mode #11616

Merged
merged 35 commits into from
Nov 22, 2017
Merged

Run Jest in production mode #11616

merged 35 commits into from
Nov 22, 2017

Commits on Nov 21, 2017

  1. Configuration menu
    Copy the full SHA
    71469e6 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    d97968f View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    3c7438a View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    6e6ce26 View commit details
    Browse the repository at this point in the history
  5. Fix the equivalence test

    It fails because the config is now passed to Jest explicitly.
    But the test doesn't know about the config.
    
    To fix this, we just run it via `yarn test` (which includes the config).
    We already depend on Yarn for development anyway.
    gaearon committed Nov 21, 2017
    Configuration menu
    Copy the full SHA
    d751fe5 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    f43aaf5 View commit details
    Browse the repository at this point in the history
  7. Actually flip the production tests to run in prod environment

    This produces a bunch of errors:
    
    Test Suites: 64 failed, 58 passed, 122 total
    Tests:       740 failed, 26 skipped, 1809 passed, 2575 total
    Snapshots:   16 failed, 4 passed, 20 total
    gaearon committed Nov 21, 2017
    Configuration menu
    Copy the full SHA
    991e359 View commit details
    Browse the repository at this point in the history
  8. Ignore expectDev() calls in production

    Down from 740 to 175 failed.
    
    Test Suites: 44 failed, 78 passed, 122 total
    Tests:       175 failed, 26 skipped, 2374 passed, 2575 total
    Snapshots:   16 failed, 4 passed, 20 total
    gaearon committed Nov 21, 2017
    Configuration menu
    Copy the full SHA
    ae39a60 View commit details
    Browse the repository at this point in the history
  9. Decode errors so tests can assert on their messages

    Down from 175 to 129.
    
    Test Suites: 33 failed, 89 passed, 122 total
    Tests:       129 failed, 1029 skipped, 1417 passed, 2575 total
    Snapshots:   16 failed, 4 passed, 20 total
    gaearon committed Nov 21, 2017
    Configuration menu
    Copy the full SHA
    8325c6d View commit details
    Browse the repository at this point in the history
  10. Remove ReactDOMProduction-test

    There is no need for it now. The only test that was special is moved into ReactDOM-test.
    gaearon committed Nov 21, 2017
    Configuration menu
    Copy the full SHA
    b8b136b View commit details
    Browse the repository at this point in the history
  11. Remove production switches from ReactErrorUtils

    The tests now run in production in a separate pass.
    gaearon committed Nov 21, 2017
    Configuration menu
    Copy the full SHA
    cabddb7 View commit details
    Browse the repository at this point in the history
  12. Add and use spyOnDev() for warnings

    This ensures that by default we expect no warnings in production bundles.
    If the warning *is* expected, use the regular spyOn() method.
    
    This currently breaks all expectDev() assertions without __DEV__ blocks so we go back to:
    
    Test Suites: 56 failed, 65 passed, 121 total
    Tests:       379 failed, 1029 skipped, 1148 passed, 2556 total
    Snapshots:   16 failed, 4 passed, 20 total
    gaearon committed Nov 21, 2017
    Configuration menu
    Copy the full SHA
    bc3027f View commit details
    Browse the repository at this point in the history
  13. Replace expectDev() with expect() in __DEV__ blocks

    We started using spyOnDev() for console warnings to ensure we don't *expect* them to occur in production. As a consequence, expectDev() assertions on console.error.calls fail because console.error.calls doesn't exist. This is actually good because it would help catch accidental warnings in production.
    
    To solve this, we are getting rid of expectDev() altogether, and instead introduce explicit expectation branches. We'd need them anyway for testing intentional behavior differences.
    
    This commit replaces all expectDev() calls with expect() calls in __DEV__ blocks. It also removes a few unnecessary expect() checks that no warnings were produced (by also removing the corresponding spyOnDev() calls).
    
    Some DEV-only assertions used plain expect(). Those were also moved into __DEV__ blocks.
    
    ReactFiberErrorLogger was special because it console.error()'s in production too. So in that case I intentionally used spyOn() instead of spyOnDev(), and added extra assertions.
    
    This gets us down to:
    
    Test Suites: 21 failed, 100 passed, 121 total
    Tests:       72 failed, 26 skipped, 2458 passed, 2556 total
    Snapshots:   16 failed, 4 passed, 20 total
    gaearon committed Nov 21, 2017
    Configuration menu
    Copy the full SHA
    22e0158 View commit details
    Browse the repository at this point in the history
  14. Enable User Timing API for production testing

    We could've disabled it, but seems like a good idea to test since we use it at FB.
    gaearon committed Nov 21, 2017
    Configuration menu
    Copy the full SHA
    efa46d3 View commit details
    Browse the repository at this point in the history
  15. Test for explicit Object.freeze() differences between PROD and DEV

    This is one of the few places where DEV and PROD behavior differs for performance reasons.
    Now we explicitly test both branches.
    gaearon committed Nov 21, 2017
    Configuration menu
    Copy the full SHA
    6e34120 View commit details
    Browse the repository at this point in the history

Commits on Nov 22, 2017

  1. Configuration menu
    Copy the full SHA
    871f2d8 View commit details
    Browse the repository at this point in the history
  2. Remove unused variable

    gaearon authored Nov 22, 2017
    Configuration menu
    Copy the full SHA
    0d2bca8 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    5ab3775 View commit details
    Browse the repository at this point in the history
  4. Fix error handling tests

    This logic is really complicated because of the global ReactFiberErrorLogger mock.
    I understand it now, so I added TODOs for later.
    
    It can be much simpler if we change the rest of the tests that assert uncaught errors to also assert they are logged as warnings.
    Which mirrors what happens in practice anyway.
    gaearon committed Nov 22, 2017
    Configuration menu
    Copy the full SHA
    623becd View commit details
    Browse the repository at this point in the history
  5. Fix more assertions

    gaearon committed Nov 22, 2017
    Configuration menu
    Copy the full SHA
    50be63d View commit details
    Browse the repository at this point in the history
  6. Change tests to document the DEV/PROD difference for state invariant

    It is very likely unintentional but I don't want to change behavior in this PR.
    Filed a follow up as facebook#11618.
    gaearon committed Nov 22, 2017
    Configuration menu
    Copy the full SHA
    9208e42 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    32dccc4 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    efc409d View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    cfdf0fc View commit details
    Browse the repository at this point in the history
  10. Fix error message assertions

    gaearon committed Nov 22, 2017
    Configuration menu
    Copy the full SHA
    7b253ff View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    4fe3b85 View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    60212f2 View commit details
    Browse the repository at this point in the history
  13. Fix the error code test

    gaearon committed Nov 22, 2017
    Configuration menu
    Copy the full SHA
    b5263d6 View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    271aff0 View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    5b40873 View commit details
    Browse the repository at this point in the history
  16. Run production tests on CI

    gaearon committed Nov 22, 2017
    Configuration menu
    Copy the full SHA
    1821d1a View commit details
    Browse the repository at this point in the history
  17. Unify configuration

    gaearon committed Nov 22, 2017
    Configuration menu
    Copy the full SHA
    8ebc499 View commit details
    Browse the repository at this point in the history
  18. Fix coverage script

    gaearon committed Nov 22, 2017
    Configuration menu
    Copy the full SHA
    6758f4c View commit details
    Browse the repository at this point in the history
  19. Configuration menu
    Copy the full SHA
    16d77e8 View commit details
    Browse the repository at this point in the history
  20. Run everything in band

    We used to before, too. I just forgot to add the arguments after deleting the script.
    gaearon committed Nov 22, 2017
    Configuration menu
    Copy the full SHA
    66e4457 View commit details
    Browse the repository at this point in the history