mirror of
https://github.com/facebookarchive/prepack.git
synced 2024-10-27 07:41:52 +03:00
5159b0d832
Summary: Currently we have a single giant file with all tests, and a giant snapshot. This is both slow, and hard to work with and iterate on. In this PR I will refactor our test setup. - [x] Split it up into multiple files (gets the test running from 45s to 27s) - [x] Run Prettier on test files - [x] Split tests further for better performance - [x] Make it possible to run one test file - [x] Fix the issue with double test re-runs in watch mode on changes in the test file - [x] Refactor error handling - [x] Run Prettier on fixtures - [x] Add a fast mode with `yarn test-react-fast <Filename>` - [x] Fix double reruns on failure Potential followups: - [x] Figure out why test interruption broke (need https://github.com/facebook/jest/issues/6599 and https://github.com/facebook/jest/issues/6598 fixed) - [x] Revisit weird things like `this['React']` assignment with a funny comment in every test Closes https://github.com/facebook/prepack/pull/2187 Differential Revision: D8713639 Pulled By: gaearon fbshipit-source-id: 5edbfa4e61610ecafff17c0e5e7f84d44cd51168
44 lines
931 B
JavaScript
44 lines
931 B
JavaScript
const React = require("react");
|
|
|
|
class Child extends React.Component {
|
|
constructor() {
|
|
super();
|
|
this.handleClick = this.handleClick.bind(this);
|
|
}
|
|
handleClick() {
|
|
// works
|
|
}
|
|
render() {
|
|
return (
|
|
<div onClick={this.handleClick}>
|
|
Numbers: {this.props.x} {this.props.y}
|
|
</div>
|
|
);
|
|
}
|
|
}
|
|
|
|
function App(props) {
|
|
let x = [];
|
|
for (let i = 0; i < 10; i++) {
|
|
x.push(<Child x={10} y={props.y} />);
|
|
}
|
|
return <div>{x}</div>;
|
|
}
|
|
|
|
App.getTrials = function(renderer, Root) {
|
|
let results = [];
|
|
|
|
renderer.update(<Root y={20} />);
|
|
results.push(["render complex class component into functional component", renderer.toJSON()]);
|
|
renderer.update(<Root y={40} />);
|
|
results.push(["update complex class component into functional component", renderer.toJSON()]);
|
|
|
|
return results;
|
|
};
|
|
|
|
if (this.__optimizeReactComponentTree) {
|
|
__optimizeReactComponentTree(App);
|
|
}
|
|
|
|
module.exports = App;
|