9442 Commits

Author SHA1 Message Date
Clement Hoang edb2b3d3a7 Update bundle sizes for 16.2.0 release v16.2.0 2017-11-28 13:29:23 -08:00
Clement Hoang 5a42586178 Updating package versions for release 16.2.0 2017-11-28 13:26:36 -08:00
Dominic Gannaway 363f4f14dc [WIP] Fix for fiber root scheduling memory leak (#11644)
* Fix for root memory leak

* forgot to add code
2017-11-28 12:57:32 -08:00
Dan Abramov c611d2c215 Amend changelog 2017-11-28 19:09:23 +00:00
rivenhk 8e876d244c Move ReactFiberTreeReflection to react-reconciler/reflection (#11683)
* Move ReactFiberTreeReflection to react-reconciler/reflection #11659

* Use * for react-reconciler

We don't know the latest local version, and release script currently doesn't bump deps automatically.

* Remove unused field

* Use CommonJS in entry point for consistency

* Undo the CommonJS change

I didn't realize it would break the build.

* Record sizes

* Remove reconciler fixtures

They're unnecessary now that we run real tests on reconciler bundles.
2017-11-28 16:57:22 +00:00
Michał Pierzchała db0454134c CI: remove unnecessary Yarn download (#11684) 2017-11-28 16:08:08 +00:00
Dan Abramov b89dc25e3f Record sizes 2017-11-28 16:03:30 +00:00
Raphael Amorim a2b6b6b206 Migrate to CircleCI2.0 and Add AppVeyor for master-only branch (#11605)
* add appveyor config file

* migrate circleci 1.0 to circleci 2.0

* remove upload step in favour of #11666
2017-11-28 14:39:18 +00:00
Jordan Tepper 7788bcdb26 Do not fail yarn linc for ignored file warning (#11615) (#11641)
* Add rule to ignore default handling of not linting hidden files

* Undo changes

* Add function to validate warnings

* Use validateWarnings when reporting linc command

* Restore files

* Contain code to line file
2017-11-28 13:54:46 +00:00
Ronald Eddy Jr b542f42a0f Update README URLS to HTTPS (#11635)
URLs were updated to use HTTPS protocol in README files.
2017-11-27 18:13:41 -08:00
Alex Cordeiro 158f040d54 Lint untracked files with yarn linc (#11665)
* Lint untracked files with yarn linc (#11646)

* Run prettier on untracked files

* Unify code for listing changed files into shared utility
2017-11-27 23:30:36 +00:00
Dan Abramov 878feebe34 Remove accidentally duplicated tests (#11675)
* Remove accidentally duplicated tests

* Refactor: move unmock() call into the only test needing it

This makes the intent more explicit.
2017-11-27 22:38:50 +00:00
Dan Abramov fe551de273 Enable bundle tests for React.Fragment (#11673) 2017-11-27 21:44:13 +00:00
Clement Hoang f6894dc48b Set fragment export flags to true (#11672) 2017-11-27 13:09:15 -08:00
Dan Abramov a65a8abc65 Use async/await in Rollup scripts (#11669) 2017-11-27 17:57:28 +00:00
Dan Abramov 018276976c Show nicer message on syntax errors 2017-11-27 15:55:46 +00:00
Dan Abramov d445cd6ea3 Bump Node devEngines to 8.x 2017-11-27 15:22:42 +00:00
Dan Abramov 0c164bb485 Upload build on the same node where it happens (#11666) 2017-11-26 18:03:30 +00:00
Adrian Carolli 53ef71b8e8 Add bundle linting and tests to the release script (#11662)
* Add bundle linting and tests to the release script

 - add yarn lint-build
- use yarn lint-build in circle ci build.sh
- add yarn lint-build, yarn test-prod, yarn test-build, and yarn test-build-prod to the realse script

* Improve readability of release test messages

* Run prettier

* Updating package versions for release 16.2.0

* Seperate bundle specific tests

- Moved the runYarnTask into utils since its being used two files now
- Uncomment out checks I mistakenly committed

* Revert a bunch of version bump changes

Mistakenly commited by release script

* .js for consistency
2017-11-26 16:47:20 +00:00
Dan Abramov f53bd033e7 Fix Jest call in the release script
Just running jest binary will no longer work
2017-11-25 16:13:28 +00:00
Anton Arboleda d1cb28c86b Refactor SyntheticKeyboardEvent tests to only use the public API (#11631)
* KeyboardEvent interface-keypress

* Pass first 6 tests

* Roll getEventCharCode-test into SyntheticKeyboardEvent-test

* Run SyntheticKeyboardEvent-test on bundles

* Remove unused code
2017-11-25 15:47:05 +00:00
Dan Abramov d235e61dc2 Don't reset error codes on CI build (#11655)
* Don't reset error codes on CI build

* Add an explanation
2017-11-25 02:23:13 +00:00
Dan Abramov f0ba6bbf20 Replace inputValueTracking-test with public API tests (#11654) 2017-11-25 01:47:10 +00:00
Ethan Arrowood a67757e115 Use only public API for ChangeEventPlugin-test.js (#11333)
* Use only public API for ChangeEventPlugin-test.js

* precommit commands complete

* Removed comments

* Improving event dispatchers

* Updated tests

* Fixed for revisions

* Prettified

* Add more details and fixes to tests

* Not internal anymore

* Remove unused code
2017-11-24 22:18:40 +00:00
Zubair Ahmed 7d27851bf4 Issue#11510: added verification check for misspelled propTypes (#11524)
* added verification check for misspelled propTypes

* added flag to check if misspelled warning was shown to developer before

* added the condition to else if and improved the warning message

* moved  variable under dev section & initialized it to false

* added test to confirm the missmatch prop type warning in both  and  tests files

* removed eslint disable and split error into 2 lines

* changed expectDev to expect in tests

* added __DEV__ condition before both tests
2017-11-24 02:59:46 +00:00
Dan Abramov 46dd197ceb Add a note about private API dependency for a test 2017-11-24 01:11:24 +00:00
Jeremias Menichelli cafe352c1a Drop .textContent IE8 polyfill and rewrite escaping tests against public API (#11331)
* Rename escapeText util. Test quoteAttributeValueForBrowser through ReactDOMServer API

* Fix lint errors

* Prettier reformatting

* Change syntax to prevent prettier escape doble quote

* Name and description gardening. Add tests for escapeTextForBrowser. Add missing tests

* Improve script tag as text content test

* Update escapeTextForBrowser-test.js

* Update quoteAttributeValueForBrowser-test.js

* Simplify tests

* Move utilities to server folder
2017-11-23 22:41:28 +00:00
Dan Abramov 575982b96d Forbid Haste in Jest (#11647) 2017-11-23 18:02:47 +00:00
Dan Abramov fa7a97fc46 Run 90% of tests on compiled bundles (both development and production) (#11633)
* Extract Jest config into a separate file

* Refactor Jest scripts directory structure

Introduces a more consistent naming scheme.

* Add yarn test-bundles and yarn test-prod-bundles

Only files ending with -test.public.js are opted in (so far we don't have any).

* Fix error decoding for production bundles

GCC seems to remove `new` from `new Error()` which broke our proxy.

* Build production version of react-noop-renderer

This lets us test more bundles.

* Switch to blacklist (exclude .private.js tests)

* Rename tests that are currently broken against bundles to *-test.internal.js

Some of these are using private APIs. Some have other issues.

* Add bundle tests to CI

* Split private and public ReactJSXElementValidator tests

* Remove internal deps from ReactServerRendering-test and make it public

* Only run tests directly in __tests__

This lets us share code between test files by placing them in __tests__/utils.

* Remove ExecutionEnvironment dependency from DOMServerIntegrationTest

It's not necessary since Stack.

* Split up ReactDOMServerIntegration into test suite and utilities

This enables us to further split it down. Good both for parallelization and extracting public parts.

* Split Fragment tests from other DOMServerIntegration tests

This enables them to opt other DOMServerIntegration tests into bundle testing.

* Split ReactDOMServerIntegration into different test files

It was way too slow to run all these in sequence.

* Don't reset the cache twice in DOMServerIntegration tests

We used to do this to simulate testing separate bundles.
But now we actually *do* test bundles. So there is no need for this, as it makes tests slower.

* Rename test-bundles* commands to test-build*

Also add test-prod-build as alias for test-build-prod because I keep messing them up.

* Use regenerator polyfill for react-noop

This fixes other issues and finally lets us run ReactNoop tests against a prod bundle.

* Run most Incremental tests against bundles

Now that GCC generator issue is fixed, we can do this.
I split ErrorLogging test separately because it does mocking. Other error handling tests don't need it.

* Update sizes

* Fix ReactMount test

* Enable ReactDOMComponent test

* Fix a warning issue uncovered by flat bundle testing

With flat bundles, we couldn't produce a good warning for <div onclick={}> on SSR
because it doesn't use the event system. However the issue was not visible in normal
Jest runs because the event plugins have been injected by the time the test ran.

To solve this, I am explicitly passing whether event system is available as an argument
to the hook. This makes the behavior consistent between source and bundle tests. Then
I change the tests to document the actual logic and _attempt_ to show a nice message
(e.g. we know for sure `onclick` is a bad event but we don't know the right name for it
on the server so we just say a generic message about camelCase naming convention).
2017-11-23 17:44:58 +00:00
Dan Abramov e949d57508 Remove global mocks by adding support for "suppressReactErrorLogging" property (#11636)
* Remove global mocks

They are making it harder to test compiled bundles.

One of them (FeatureFlags) is not used. It is mocked in some specific test files (and that's fine).

The other (FiberErrorLogger) is mocked to silence its output. I'll look if there's some other way to achieve this.

* Add error.suppressReactErrorLogging and use it in tests

This adds an escape hatch to *not* log errors that go through React to the console.
We will enable it for our own tests.
2017-11-23 01:15:22 +00:00
Alex Cordeiro f114bad09f Bug fix - SetState callback called before component state is updated in ReactShallowRenderer (#11507)
* Create test to verify ReactShallowRenderer bug (#11496)

* Fix ReactShallowRenderer callback bug on componentWillMount (#11496)

* Improve fnction naming and clean up queued callback before call

* Run prettier on ReactShallowRenderer.js

* Consolidate callback call on ReactShallowRenderer.js

* Ensure callback behavior is similar between ReactDOM and ReactShallowRenderer

* Fix Code Review requests (#11507)

* Move test to ReactCompositeComponent

* Verify the callback gets called

* Ensure multiple callbacks are correctly handled on ReactShallowRenderer

* Ensure the setState callback is called inside componentWillMount (ReactDOM)

* Clear ReactShallowRenderer callback queue before actually calling the callbacks

* Add test for multiple callbacks on ReactShallowRenderer

* Ensure the ReactShallowRenderer callback queue is cleared after invoking callbacks

* Remove references to internal fields on ReactShallowRenderer test
2017-11-22 22:15:11 +00:00
Dan Abramov 913a125ad5 Change DEV-only invariants to be warnings (#11630)
* Change DEV-only invariant about instance.state type to a warning

* Change DEV-only invariant childContextTypes check to a warning
2017-11-22 18:58:53 +00:00
Dan Abramov 1cb6199d22 Consolidate all symbols in a single file (#11629)
* Consolidate all symbols in a single file

This reduces the code duplication as we have quite a few now.

* Record sizes
2017-11-22 18:08:22 +00:00
Dan Abramov d1f6fbd22a Record sizes 2017-11-22 16:15:04 +00:00
Dan Abramov 4c451f7f2b Add yarn test-prod to pull request steps 2017-11-22 13:11:07 +00:00
Dan Abramov 6041f481b7 Run Jest in production mode (#11616)
* Move Jest setup files to /dev/ subdirectory

* Clone Jest /dev/ files into /prod/

* Move shared code into scripts/jest

* Move Jest config into the scripts folder

* 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.

* Add yarn test-prod to run Jest with production environment

* 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

* 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

* 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

* Remove ReactDOMProduction-test

There is no need for it now. The only test that was special is moved into ReactDOM-test.

* Remove production switches from ReactErrorUtils

The tests now run in production in a separate pass.

* 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

* 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

* 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.

* 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.

* Run Jest via "yarn test" on CI

* Remove unused variable

* Assert different error messages

* 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.

* Fix more assertions

* 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 https://github.com/facebook/react/issues/11618.

* Remove unnecessary split between DEV/PROD ref tests

* Fix more test message assertions

* Make validateDOMNesting tests DEV-only

* Fix error message assertions

* Document existing DEV/PROD message difference (possible bug)

* Change mocking assertions to be DEV-only

* Fix the error code test

* Fix more error message assertions

* Fix the last failing test due to known issue

* Run production tests on CI

* Unify configuration

* Fix coverage script

* Remove expectDev from eslintrc

* Run everything in band

We used to before, too. I just forgot to add the arguments after deleting the script.
2017-11-22 13:02:26 +00:00
Dan Abramov 7e7127387b Run Jest tests with "development" environment (#11612) 2017-11-21 16:28:42 +00:00
Dan Abramov 40a176d859 Remove mentions of module map in Jest config (#11611) 2017-11-21 16:01:10 +00:00
Bryce Kalow 7e692fb496 Fixes typo in eslint script (#11607) 2017-11-21 02:46:57 +00:00
Matteo Vesprini-Heidrich c6bde7b99f support Call and Return components in React.Children calls (#11422)
* support Call and Return components in React.Children calls

* make tests more verbose

* fix ordering of React component types

* cleanup conditional detection of children type

* directly inline callback invocation

* reduce callback invocation code re-use
2017-11-20 22:06:37 +00:00
Brian Vaughn dbf715c958 Read debugRenderPhaseSideEffects from GK (#11603)
* Forked ReactFeatureFlags for React Native to enable debugRenderPhaseSideEffects GK
* Changed debugRenderPhaseSideEffects in www feature flags to be runtime as well
2017-11-20 14:05:53 -08:00
Andy Davies adcf980333 Re-enable UMD build for TestUtils (#11599)
Fixes #11111
2017-11-20 12:41:01 -05:00
Tim Jacobi 669a70dab7 Rewrite SyntheticEvent tests using public APIs only (#11525)
* generate synthetics events using public API

* rewritten createEvent to use public APIs
* removed all references SyntheticEvent.release

In order to test under realistic circumstances I had to move
the expectations into a callback in mosts tests to overcome
the effects of event pooling.

* run prettier

* remove empty line

* don't use ReactTestUtils

* run prettier and fix linter issues

* remove duplicate test

* remove invalid calls to expect

The removed `expect` calls verified the correct behaviour based on
missing `preventDefault` and `stopPropagation` methods.
The was correct as we used plain objects to simulate events.
Since we switched to the public API we're using native events which
do have these methods.

* set event.defaultPrevented to undefined

This was missed when the test was first migrated.
When emulating IE8 not only has returnValue to be false.
In addition defaultPrevented must not be defined.

* run all tests and format code

* rename instance variable to node

* remove backtick

* only simulate IE in normalisation test

* include assignment in definition

* add missing `persist` test

* use method instead of field to prevent default

* expect properties to be unchanged on persisted event

* optimise tests that deal with event persitence

* declare and assign `event` on the same line if not reassigned later
2017-11-20 14:29:27 +00:00
cristidrg bd9dbd5d60 Remove MouseWheel and MouseDOMScroll event patching
The `wheel` event has not always been supported in every browser. React would fall back to `mousewheel` and `DOMMouseScroll` when the `wheel` event was not available. All supported browsers provide the `wheel` event. This code is no longer necessary.
2017-11-20 07:40:57 -05:00
Nathan Hunzaker 57aef3f00e Format test fixtures 2017-11-19 12:12:46 -05:00
landvibe 70abda5b92 Switching the name property preserves radio selection
Fixes a case where changing the name and checked value of a radio button in the same update would lead to checking the wrong radio input. Also adds a DOM test fixture for related issue.

Related issues:
https://github.com/facebook/react/issues/7630
2017-11-19 10:44:35 -05:00
Raphael Amorim 3f405da614 Migrating to const/let and Object Spread in more places (#11535)
* Use const/let in more places (#11467)

* Convert ReactDOMFiberTextarea to const/let
* Convert ReactDOMSelection to const/let
* Convert setTextContent to const/let
* Convert validateDOMNesting to const/let

* Replace Object.assign by Object Spread

* Convert ReactDOMFiberOption to Object Spread
* Convert ReactDOMFiberTextarea to Object Spread
* Convert validateDOMNesting to Object Spread
2017-11-19 14:53:55 +00:00
Soo Jae Hwang 962042f827 Improve formatting of errors when building (#11456)
* Improve formatting of errors when building

* Remove undefined from the header when error.plugin is undefined

* Add babel-code-frame and syntax highlighting in error message

* Run yarn prettier and fix code format
2017-11-19 14:23:33 +00:00
Gordon Dent aa0b7418c1 Rewrite ReactDOMComponentTree-test to test behavior using Public API (#11383)
* Rewrite ReactDOMComponentTree-test to test behavior using Public API

 - Part of #11299
 - I've tried to identify cases where code within ReactDOMComponentTree is exercised and have updated accordingly but I'm not entirely sure whether I'm on the right track. I thought I'd PR to get feedback from the community. Looking forward to comments.

* Prettier and lint changes

* Remove testing of internals and add test cases for testing behavior exhibited after use of getInstanceFromNode

* [RFC] Update testing approach to verify exhibited behavior dependent upon methods in ReactDOMComponentTree

* Remove tests from event handlers and use sync tests

* Prettier changes

* Rename variables to be more semantic

* Prettier updates

* Update test following review

 - Use beforeEach and afterEach to set up and tear down container element for use in each test
 - Move any functions specific to one test to within test body (improves readability imo)

* Add coverage for getNodeFromInstance and implementation of getFiberCurrentPropsFromNode
 - After researching usage of getNodeFromInstance we can test getNodeFromInstance dispatching some events and asserting the id of the currentTarget
 - After checking git blame for getFiberCurrentPropsFromNode and reading through #8607 I found a test that we can simplify to assert behavior of the function by ensuring event handler props are updated from the fiber props. Swapping out the implementation of this function with `return node[internalInstanceKey].memoizedProps` results in a failure.
2017-11-19 14:18:16 +00:00
Soo Jae Hwang 01a867b3ea Upgrade rollup dependency (#11591)
* Record build results before upgrading rollup

* Upgrade rollup and record new results.json
2017-11-18 13:49:40 +00:00