From d99a17cc4bdead7a702a10e9252f380aaf4fa231 Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Sat, 4 Feb 2017 12:43:27 -0500 Subject: [PATCH 01/10] Less magic is better for the future generations. --- .../fixtures/kitchensink/.babelrc | 3 +- .../kitchensink/.template.dependencies.json | 1 + .../fixtures/kitchensink/src/App.js | 42 ++++++++++++------- .../kitchensink/src/features/env/NodePath.js | 24 +++++++---- .../src/features/syntax/ArrayDestructuring.js | 24 +++++++---- .../src/features/syntax/ArraySpread.js | 24 +++++++---- .../src/features/syntax/AsyncAwait.js | 24 +++++++---- .../src/features/syntax/ClassProperties.js | 16 ++++++- .../src/features/syntax/ComputedProperties.js | 24 +++++++---- .../features/syntax/CustomInterpolation.js | 24 +++++++---- .../src/features/syntax/DefaultParameters.js | 24 +++++++---- .../features/syntax/DestructuringAndAwait.js | 24 +++++++---- .../src/features/syntax/Generators.js | 24 +++++++---- .../features/syntax/ObjectDestructuring.js | 24 +++++++---- .../src/features/syntax/ObjectSpread.js | 24 +++++++---- .../src/features/syntax/Promises.js | 24 +++++++---- .../src/features/syntax/RestAndDefault.js | 24 +++++++---- .../src/features/syntax/RestParameters.js | 24 +++++++---- .../features/syntax/TemplateInterpolation.js | 24 +++++++---- 19 files changed, 269 insertions(+), 153 deletions(-) diff --git a/packages/react-scripts/fixtures/kitchensink/.babelrc b/packages/react-scripts/fixtures/kitchensink/.babelrc index 5686105b953..e2f4ed63f00 100644 --- a/packages/react-scripts/fixtures/kitchensink/.babelrc +++ b/packages/react-scripts/fixtures/kitchensink/.babelrc @@ -1,3 +1,4 @@ { - "presets": ["latest"] + "presets": ["latest"], + "plugins": ["transform-class-properties"] } diff --git a/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json b/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json index 62e0d34a35c..0363856d34b 100644 --- a/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json +++ b/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json @@ -3,6 +3,7 @@ "babel-preset-latest": "6.16.0", "babel-register": "6.22.0", "babel-polyfill": "6.20.0", + "babel-plugin-transform-class-properties": "6.22.0", "chai": "3.5.0", "jsdom": "9.8.3", "mocha": "3.2.0" diff --git a/packages/react-scripts/fixtures/kitchensink/src/App.js b/packages/react-scripts/fixtures/kitchensink/src/App.js index cf93b4c132b..479f5f38959 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/App.js +++ b/packages/react-scripts/fixtures/kitchensink/src/App.js @@ -1,24 +1,33 @@ -import React from 'react'; +import React, { Component, PropTypes, createElement } from 'react'; class BuiltEmitter extends React.Component { - constructor(props) { - super(props) - - this.callWhenDone = done => done(); + static propTypes = { + feature: PropTypes.func.isRequired } componentDidMount() { - this.callWhenDone(() => document.dispatchEvent(new Event('ReactFeatureDidMount'))); + const { feature } = this.props + if (!Component.isPrototypeOf(feature)) { + this.notifyRendered(); + } } - render() { - const feature = React.cloneElement(React.Children.only(this.props.children), { - setCallWhenDone: done => { - this.callWhenDone = done; - } - }); + notifyRendered() { + document.dispatchEvent(new Event('ReactFeatureDidMount')); + } - return
{feature}
; + render() { + const { + props: { feature }, + notifyRendered + } = this; + return ( +
+ {createElement(feature, { + notifyRendered + })} +
+ ); } } @@ -116,8 +125,11 @@ class App extends React.Component { } render() { - const Feature = this.state.feature; - return Feature ? : null; + const { feature } = this.state; + if (feature !== null) { + return ; + } + return null } } diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/env/NodePath.js b/packages/react-scripts/fixtures/kitchensink/src/features/env/NodePath.js index 1644b49ca04..ea9117b32c7 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/env/NodePath.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/env/NodePath.js @@ -1,21 +1,27 @@ -import React from 'react' +import React, { Component, PropTypes } from 'react' import load from 'absoluteLoad' -export default class extends React.Component { - constructor(props) { - super(props); +export default class extends Component { + static propTypes = { + notifyRendered: PropTypes.func + } - this.done = () => {}; - this.props.setCallWhenDone && this.props.setCallWhenDone((done) => { - this.done = done; - }); + static defaultProps = { + notifyRendered: () => {} + } + constructor(props) { + super(props); this.state = { users: [] }; } async componentDidMount() { const users = load(); - this.setState({ users }, () => this.done()); + this.setState({ users }); + } + + componentDidUpdate() { + this.props.notifyRendered(); } render() { diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArrayDestructuring.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArrayDestructuring.js index 1ee751af71f..26c6e2b01e2 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArrayDestructuring.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArrayDestructuring.js @@ -1,4 +1,4 @@ -import React from 'react' +import React, { Component, PropTypes } from 'react' function load() { return [ @@ -9,21 +9,27 @@ function load() { ]; } -export default class extends React.Component { - constructor(props) { - super(props); +export default class extends Component { + static propTypes = { + notifyRendered: PropTypes.func + } - this.done = () => {}; - this.props.setCallWhenDone && this.props.setCallWhenDone((done) => { - this.done = done; - }); + static defaultProps = { + notifyRendered: () => {} + } + constructor(props) { + super(props); this.state = { users: [] }; } async componentDidMount() { const users = load(); - this.setState({ users }, () => this.done()); + this.setState({ users }); + } + + componentDidUpdate() { + this.props.notifyRendered(); } render() { diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArraySpread.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArraySpread.js index be6311980d7..03fc2cbc1f8 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArraySpread.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArraySpread.js @@ -1,4 +1,4 @@ -import React from 'react' +import React, { Component, PropTypes } from 'react' function load(users) { return [ @@ -9,21 +9,27 @@ function load(users) { ]; } -export default class extends React.Component { - constructor(props) { - super(props); +export default class extends Component { + static propTypes = { + notifyRendered: PropTypes.func + } - this.done = () => {}; - this.props.setCallWhenDone && this.props.setCallWhenDone((done) => { - this.done = done; - }); + static defaultProps = { + notifyRendered: () => {} + } + constructor(props) { + super(props); this.state = { users: [] }; } async componentDidMount() { const users = load([{ id: 42, name: '42' }]); - this.setState({ users }, () => this.done()); + this.setState({ users }); + } + + componentDidUpdate() { + this.props.notifyRendered(); } render() { diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/AsyncAwait.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/AsyncAwait.js index 84dd42e0a9b..8b72a7edb2e 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/AsyncAwait.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/AsyncAwait.js @@ -1,4 +1,4 @@ -import React from 'react' +import React, { Component, PropTypes } from 'react' async function load() { return [ @@ -9,21 +9,27 @@ async function load() { ]; } -export default class extends React.Component { - constructor(props) { - super(props); +export default class extends Component { + static propTypes = { + notifyRendered: PropTypes.func + } - this.done = () => {}; - this.props.setCallWhenDone && this.props.setCallWhenDone((done) => { - this.done = done; - }); + static defaultProps = { + notifyRendered: () => {} + } + constructor(props) { + super(props); this.state = { users: [] }; } async componentDidMount() { const users = await load(); - this.setState({ users }, () => this.done()); + this.setState({ users }); + } + + componentDidUpdate() { + this.props.notifyRendered(); } render() { diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ClassProperties.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ClassProperties.js index 65e500d645b..cae6369dead 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ClassProperties.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ClassProperties.js @@ -1,6 +1,14 @@ -import React from 'react' +import React, { Component, PropTypes } from 'react' + +export default class extends Component { + static propTypes = { + notifyRendered: PropTypes.func + } + + static defaultProps = { + notifyRendered: () => {} + } -export default class extends React.Component { users = [ { id: 1, name: '1' }, { id: 2, name: '2' }, @@ -8,6 +16,10 @@ export default class extends React.Component { { id: 4, name: '4' } ]; + componentDidMount() { + this.props.notifyRendered() + } + render() { return (
diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ComputedProperties.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ComputedProperties.js index b6111a149d9..e99475724e8 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ComputedProperties.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ComputedProperties.js @@ -1,4 +1,4 @@ -import React from 'react' +import React, { Component, PropTypes } from 'react' function load(prefix) { return [ @@ -9,21 +9,27 @@ function load(prefix) { ]; } -export default class extends React.Component { - constructor(props) { - super(props); +export default class extends Component { + static propTypes = { + notifyRendered: PropTypes.func + } - this.done = () => {}; - this.props.setCallWhenDone && this.props.setCallWhenDone((done) => { - this.done = done; - }); + static defaultProps = { + notifyRendered: () => {} + } + constructor(props) { + super(props); this.state = { users: [] }; } async componentDidMount() { const users = load('user_'); - this.setState({ users }, () => this.done()); + this.setState({ users }); + } + + componentDidUpdate() { + this.props.notifyRendered(); } render() { diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/CustomInterpolation.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/CustomInterpolation.js index 8184d3bd4ba..3db481dbbea 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/CustomInterpolation.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/CustomInterpolation.js @@ -1,4 +1,4 @@ -import React from 'react' +import React, { Component, PropTypes } from 'react' const styled = ([style]) => style.trim() .split(/\s*;\s*/) @@ -14,21 +14,27 @@ function load() { ]; } -export default class extends React.Component { - constructor(props) { - super(props); +export default class extends Component { + static propTypes = { + notifyRendered: PropTypes.func + } - this.done = () => {}; - this.props.setCallWhenDone && this.props.setCallWhenDone((done) => { - this.done = done; - }); + static defaultProps = { + notifyRendered: () => {} + } + constructor(props) { + super(props); this.state = { users: [] }; } async componentDidMount() { const users = load(); - this.setState({ users }, () => this.done()); + this.setState({ users }); + } + + componentDidUpdate() { + this.props.notifyRendered(); } render() { diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DefaultParameters.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DefaultParameters.js index 637a239d7a4..1f8d9c2441e 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DefaultParameters.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DefaultParameters.js @@ -1,4 +1,4 @@ -import React from 'react' +import React, { Component, PropTypes } from 'react' function load(id = 0) { return [ @@ -9,21 +9,27 @@ function load(id = 0) { ]; } -export default class extends React.Component { - constructor(props) { - super(props); +export default class extends Component { + static propTypes = { + notifyRendered: PropTypes.func + } - this.done = () => {}; - this.props.setCallWhenDone && this.props.setCallWhenDone((done) => { - this.done = done; - }); + static defaultProps = { + notifyRendered: () => {} + } + constructor(props) { + super(props); this.state = { users: [] }; } async componentDidMount() { const users = load(); - this.setState({ users }, () => this.done()); + this.setState({ users }); + } + + componentDidUpdate() { + this.props.notifyRendered(); } render() { diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DestructuringAndAwait.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DestructuringAndAwait.js index e28e0bb3643..0cf77c696b4 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DestructuringAndAwait.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DestructuringAndAwait.js @@ -1,4 +1,4 @@ -import React from 'react' +import React, { Component, PropTypes } from 'react' async function load() { return { users: [ @@ -9,21 +9,27 @@ async function load() { ] }; } -export default class extends React.Component { - constructor(props) { - super(props); +export default class extends Component { + static propTypes = { + notifyRendered: PropTypes.func + } - this.done = () => {}; - this.props.setCallWhenDone && this.props.setCallWhenDone((done) => { - this.done = done; - }); + static defaultProps = { + notifyRendered: () => {} + } + constructor(props) { + super(props); this.state = { users: [] }; } async componentDidMount() { const { users } = await load(); - this.setState({ users }, () => this.done()); + this.setState({ users }); + } + + componentDidUpdate() { + this.props.notifyRendered(); } render() { diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Generators.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Generators.js index a20fc19b75f..e6a7a115618 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Generators.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Generators.js @@ -1,4 +1,4 @@ -import React from 'react' +import React, { Component, PropTypes } from 'react' function * load(limit) { let i = 1; @@ -8,15 +8,17 @@ function * load(limit) { } } -export default class extends React.Component { - constructor(props) { - super(props); +export default class extends Component { + static propTypes = { + notifyRendered: PropTypes.func + } - this.done = () => {}; - this.props.setCallWhenDone && this.props.setCallWhenDone((done) => { - this.done = done; - }); + static defaultProps = { + notifyRendered: () => {} + } + constructor(props) { + super(props); this.state = { users: [] }; } @@ -25,7 +27,11 @@ export default class extends React.Component { for (let user of load(4)) { users.push(user); } - this.setState({ users }, () => this.done()); + this.setState({ users }); + } + + componentDidUpdate() { + this.props.notifyRendered(); } render() { diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectDestructuring.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectDestructuring.js index db377cee5e6..21f6d667af2 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectDestructuring.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectDestructuring.js @@ -1,4 +1,4 @@ -import React from 'react' +import React, { Component, PropTypes } from 'react' function load() { return [ @@ -9,21 +9,27 @@ function load() { ]; } -export default class extends React.Component { - constructor(props) { - super(props); +export default class extends Component { + static propTypes = { + notifyRendered: PropTypes.func + } - this.done = () => {}; - this.props.setCallWhenDone && this.props.setCallWhenDone((done) => { - this.done = done; - }); + static defaultProps = { + notifyRendered: () => {} + } + constructor(props) { + super(props); this.state = { users: [] }; } async componentDidMount() { const users = load(); - this.setState({ users }, () => this.done()); + this.setState({ users }); + } + + componentDidUpdate() { + this.props.notifyRendered(); } render() { diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectSpread.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectSpread.js index 72356fb9404..31bcc124d76 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectSpread.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectSpread.js @@ -1,4 +1,4 @@ -import React from 'react' +import React, { Component, PropTypes } from 'react' function load(baseUser) { return [ @@ -9,21 +9,27 @@ function load(baseUser) { ]; } -export default class extends React.Component { - constructor(props) { - super(props); +export default class extends Component { + static propTypes = { + notifyRendered: PropTypes.func + } - this.done = () => {}; - this.props.setCallWhenDone && this.props.setCallWhenDone((done) => { - this.done = done; - }); + static defaultProps = { + notifyRendered: () => {} + } + constructor(props) { + super(props); this.state = { users: [] }; } async componentDidMount() { const users = load({ age: 42 }); - this.setState({ users }, () => this.done()); + this.setState({ users }); + } + + componentDidUpdate() { + this.props.notifyRendered(); } render() { diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Promises.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Promises.js index 9eb8c20f790..00bd434f41f 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Promises.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Promises.js @@ -1,4 +1,4 @@ -import React from 'react' +import React, { Component, PropTypes } from 'react' function load() { return Promise.resolve([ @@ -9,24 +9,30 @@ function load() { ]); } -export default class extends React.Component { - constructor(props) { - super(props); +export default class extends Component { + static propTypes = { + notifyRendered: PropTypes.func + } - this.done = () => {}; - this.props.setCallWhenDone && this.props.setCallWhenDone((done) => { - this.done = done; - }); + static defaultProps = { + notifyRendered: () => {} + } + constructor(props) { + super(props); this.state = { users: [] }; } componentDidMount() { load().then(users => { - this.setState({ users }, () => this.done()); + this.setState({ users }); }); } + componentDidUpdate() { + this.props.notifyRendered(); + } + render() { return (
diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestAndDefault.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestAndDefault.js index 94b75980835..99d2a051612 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestAndDefault.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestAndDefault.js @@ -1,4 +1,4 @@ -import React from 'react' +import React, { Component, PropTypes } from 'react' function load({ id, ...rest } = { id: 0, user: { id: 42, name: '42' } }) { return [ @@ -9,21 +9,27 @@ function load({ id, ...rest } = { id: 0, user: { id: 42, name: '42' } }) { ]; } -export default class extends React.Component { - constructor(props) { - super(props); +export default class extends Component { + static propTypes = { + notifyRendered: PropTypes.func + } - this.done = () => {}; - this.props.setCallWhenDone && this.props.setCallWhenDone((done) => { - this.done = done; - }); + static defaultProps = { + notifyRendered: () => {} + } + constructor(props) { + super(props); this.state = { users: [] }; } async componentDidMount() { const users = load(); - this.setState({ users }, () => this.done()); + this.setState({ users }); + } + + componentDidUpdate() { + this.props.notifyRendered(); } render() { diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestParameters.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestParameters.js index c1cd63e887e..096856b5397 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestParameters.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestParameters.js @@ -1,4 +1,4 @@ -import React from 'react' +import React, { Component, PropTypes } from 'react' function load({ id = 0, ...rest }) { return [ @@ -9,21 +9,27 @@ function load({ id = 0, ...rest }) { ]; } -export default class extends React.Component { - constructor(props) { - super(props); +export default class extends Component { + static propTypes = { + notifyRendered: PropTypes.func + } - this.done = () => {}; - this.props.setCallWhenDone && this.props.setCallWhenDone((done) => { - this.done = done; - }); + static defaultProps = { + notifyRendered: () => {} + } + constructor(props) { + super(props); this.state = { users: [] }; } async componentDidMount() { const users = load({ id: 0, user: { id: 42, name: '42' } }); - this.setState({ users }, () => this.done()); + this.setState({ users }); + } + + componentDidUpdate() { + this.props.notifyRendered(); } render() { diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/TemplateInterpolation.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/TemplateInterpolation.js index 33b004722d8..916e271b381 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/TemplateInterpolation.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/TemplateInterpolation.js @@ -1,4 +1,4 @@ -import React from 'react' +import React, { Component, PropTypes } from 'react' function load(name) { return [ @@ -9,21 +9,27 @@ function load(name) { ]; } -export default class extends React.Component { - constructor(props) { - super(props); +export default class extends Component { + static propTypes = { + notifyRendered: PropTypes.func + } - this.done = () => {}; - this.props.setCallWhenDone && this.props.setCallWhenDone((done) => { - this.done = done; - }); + static defaultProps = { + notifyRendered: () => {} + } + constructor(props) { + super(props); this.state = { users: [] }; } async componentDidMount() { const users = load('user_'); - this.setState({ users }, () => this.done()); + this.setState({ users }); + } + + componentDidUpdate() { + this.props.notifyRendered(); } render() { From 271d5b830015d29033d134147d8a2bc90d43d5f0 Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Sat, 4 Feb 2017 15:40:04 -0500 Subject: [PATCH 02/10] Notify rendered in Jest --- .../fixtures/kitchensink/src/features/env/NodePath.js | 6 +----- .../fixtures/kitchensink/src/features/env/NodePath.test.js | 4 +++- .../kitchensink/src/features/syntax/ArrayDestructuring.js | 6 +----- .../src/features/syntax/ArrayDestructuring.test.js | 4 +++- .../fixtures/kitchensink/src/features/syntax/ArraySpread.js | 6 +----- .../kitchensink/src/features/syntax/ArraySpread.test.js | 4 +++- .../fixtures/kitchensink/src/features/syntax/AsyncAwait.js | 6 +----- .../kitchensink/src/features/syntax/AsyncAwait.test.js | 4 +++- .../kitchensink/src/features/syntax/ClassProperties.js | 6 +----- .../kitchensink/src/features/syntax/ClassProperties.test.js | 4 +++- .../kitchensink/src/features/syntax/ComputedProperties.js | 6 +----- .../src/features/syntax/ComputedProperties.test.js | 4 +++- .../kitchensink/src/features/syntax/CustomInterpolation.js | 6 +----- .../src/features/syntax/CustomInterpolation.test.js | 4 +++- .../kitchensink/src/features/syntax/DefaultParameters.js | 6 +----- .../src/features/syntax/DefaultParameters.test.js | 4 +++- .../src/features/syntax/DestructuringAndAwait.js | 6 +----- .../src/features/syntax/DestructuringAndAwait.test.js | 4 +++- .../fixtures/kitchensink/src/features/syntax/Generators.js | 6 +----- .../kitchensink/src/features/syntax/Generators.test.js | 4 +++- .../kitchensink/src/features/syntax/ObjectDestructuring.js | 6 +----- .../src/features/syntax/ObjectDestructuring.test.js | 4 +++- .../kitchensink/src/features/syntax/ObjectSpread.js | 6 +----- .../kitchensink/src/features/syntax/ObjectSpread.test.js | 4 +++- .../fixtures/kitchensink/src/features/syntax/Promises.js | 6 +----- .../kitchensink/src/features/syntax/Promises.test.js | 4 +++- .../kitchensink/src/features/syntax/RestAndDefault.js | 6 +----- .../kitchensink/src/features/syntax/RestAndDefault.test.js | 4 +++- .../kitchensink/src/features/syntax/RestParameters.js | 6 +----- .../kitchensink/src/features/syntax/RestParameters.test.js | 4 +++- .../src/features/syntax/TemplateInterpolation.js | 6 +----- .../src/features/syntax/TemplateInterpolation.test.js | 4 +++- 32 files changed, 64 insertions(+), 96 deletions(-) diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/env/NodePath.js b/packages/react-scripts/fixtures/kitchensink/src/features/env/NodePath.js index ea9117b32c7..5479d3c7ce0 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/env/NodePath.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/env/NodePath.js @@ -3,11 +3,7 @@ import load from 'absoluteLoad' export default class extends Component { static propTypes = { - notifyRendered: PropTypes.func - } - - static defaultProps = { - notifyRendered: () => {} + notifyRendered: PropTypes.func.isRequired } constructor(props) { diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/env/NodePath.test.js b/packages/react-scripts/fixtures/kitchensink/src/features/env/NodePath.test.js index 05b981853b9..abe62b2f49c 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/env/NodePath.test.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/env/NodePath.test.js @@ -5,6 +5,8 @@ import NodePath from './NodePath'; describe('NODE_PATH', () => { it('renders without crashing', () => { const div = document.createElement('div'); - ReactDOM.render(, div); + return new Promise(resolve => { + ReactDOM.render(, div); + }); }); }); diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArrayDestructuring.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArrayDestructuring.js index 26c6e2b01e2..06779c05eee 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArrayDestructuring.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArrayDestructuring.js @@ -11,11 +11,7 @@ function load() { export default class extends Component { static propTypes = { - notifyRendered: PropTypes.func - } - - static defaultProps = { - notifyRendered: () => {} + notifyRendered: PropTypes.func.isRequired } constructor(props) { diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArrayDestructuring.test.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArrayDestructuring.test.js index 617df2a6c6c..1e636f548c7 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArrayDestructuring.test.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArrayDestructuring.test.js @@ -5,6 +5,8 @@ import ArrayDestructuring from './ArrayDestructuring'; describe('array destructuring', () => { it('renders without crashing', () => { const div = document.createElement('div'); - ReactDOM.render(, div); + return new Promise(resolve => { + ReactDOM.render(, div); + }); }); }); diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArraySpread.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArraySpread.js index 03fc2cbc1f8..e46de969a30 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArraySpread.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArraySpread.js @@ -11,11 +11,7 @@ function load(users) { export default class extends Component { static propTypes = { - notifyRendered: PropTypes.func - } - - static defaultProps = { - notifyRendered: () => {} + notifyRendered: PropTypes.func.isRequired } constructor(props) { diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArraySpread.test.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArraySpread.test.js index 85fade6e3a9..d905b7295c5 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArraySpread.test.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArraySpread.test.js @@ -5,6 +5,8 @@ import ArraySpread from './ArraySpread'; describe('array spread', () => { it('renders without crashing', () => { const div = document.createElement('div'); - ReactDOM.render(, div); + return new Promise(resolve => { + ReactDOM.render(, div); + }); }); }); diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/AsyncAwait.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/AsyncAwait.js index 8b72a7edb2e..aed435b1cf6 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/AsyncAwait.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/AsyncAwait.js @@ -11,11 +11,7 @@ async function load() { export default class extends Component { static propTypes = { - notifyRendered: PropTypes.func - } - - static defaultProps = { - notifyRendered: () => {} + notifyRendered: PropTypes.func.isRequired } constructor(props) { diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/AsyncAwait.test.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/AsyncAwait.test.js index 072f16fffea..279d053a527 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/AsyncAwait.test.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/AsyncAwait.test.js @@ -5,6 +5,8 @@ import AsyncAwait from './AsyncAwait'; describe('async/await', () => { it('renders without crashing', () => { const div = document.createElement('div'); - ReactDOM.render(, div); + return new Promise(resolve => { + ReactDOM.render(, div); + }); }); }); diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ClassProperties.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ClassProperties.js index cae6369dead..9397aabdca9 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ClassProperties.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ClassProperties.js @@ -2,11 +2,7 @@ import React, { Component, PropTypes } from 'react' export default class extends Component { static propTypes = { - notifyRendered: PropTypes.func - } - - static defaultProps = { - notifyRendered: () => {} + notifyRendered: PropTypes.func.isRequired } users = [ diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ClassProperties.test.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ClassProperties.test.js index 71d851dd2fc..1db9e2ed5d2 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ClassProperties.test.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ClassProperties.test.js @@ -5,6 +5,8 @@ import ClassProperties from './ClassProperties'; describe('class properties', () => { it('renders without crashing', () => { const div = document.createElement('div'); - ReactDOM.render(, div); + return new Promise(resolve => { + ReactDOM.render(, div); + }); }); }); diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ComputedProperties.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ComputedProperties.js index e99475724e8..fa9b22cab7e 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ComputedProperties.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ComputedProperties.js @@ -11,11 +11,7 @@ function load(prefix) { export default class extends Component { static propTypes = { - notifyRendered: PropTypes.func - } - - static defaultProps = { - notifyRendered: () => {} + notifyRendered: PropTypes.func.isRequired } constructor(props) { diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ComputedProperties.test.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ComputedProperties.test.js index 4e9aaf17a1d..1c9742d75b0 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ComputedProperties.test.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ComputedProperties.test.js @@ -5,6 +5,8 @@ import ComputedProperties from './ComputedProperties'; describe('computed properties', () => { it('renders without crashing', () => { const div = document.createElement('div'); - ReactDOM.render(, div); + return new Promise(resolve => { + ReactDOM.render(, div); + }); }); }); diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/CustomInterpolation.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/CustomInterpolation.js index 3db481dbbea..9a505770d08 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/CustomInterpolation.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/CustomInterpolation.js @@ -16,11 +16,7 @@ function load() { export default class extends Component { static propTypes = { - notifyRendered: PropTypes.func - } - - static defaultProps = { - notifyRendered: () => {} + notifyRendered: PropTypes.func.isRequired } constructor(props) { diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/CustomInterpolation.test.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/CustomInterpolation.test.js index 10b1df278c1..5bc1b2442e8 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/CustomInterpolation.test.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/CustomInterpolation.test.js @@ -5,6 +5,8 @@ import CustomInterpolation from './CustomInterpolation'; describe('custom interpolation', () => { it('renders without crashing', () => { const div = document.createElement('div'); - ReactDOM.render(, div); + return new Promise(resolve => { + ReactDOM.render(, div); + }); }); }); diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DefaultParameters.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DefaultParameters.js index 1f8d9c2441e..6e0cefc7934 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DefaultParameters.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DefaultParameters.js @@ -11,11 +11,7 @@ function load(id = 0) { export default class extends Component { static propTypes = { - notifyRendered: PropTypes.func - } - - static defaultProps = { - notifyRendered: () => {} + notifyRendered: PropTypes.func.isRequired } constructor(props) { diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DefaultParameters.test.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DefaultParameters.test.js index b5ece244681..ebb59d715e5 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DefaultParameters.test.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DefaultParameters.test.js @@ -5,6 +5,8 @@ import DefaultParameters from './DefaultParameters'; describe('default parameters', () => { it('renders without crashing', () => { const div = document.createElement('div'); - ReactDOM.render(, div); + return new Promise(resolve => { + ReactDOM.render(, div); + }); }); }); diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DestructuringAndAwait.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DestructuringAndAwait.js index 0cf77c696b4..56ff8a31c80 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DestructuringAndAwait.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DestructuringAndAwait.js @@ -11,11 +11,7 @@ async function load() { export default class extends Component { static propTypes = { - notifyRendered: PropTypes.func - } - - static defaultProps = { - notifyRendered: () => {} + notifyRendered: PropTypes.func.isRequired } constructor(props) { diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DestructuringAndAwait.test.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DestructuringAndAwait.test.js index 14521e30798..ab242de3bb8 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DestructuringAndAwait.test.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DestructuringAndAwait.test.js @@ -5,6 +5,8 @@ import DestructuringAndAwait from './DestructuringAndAwait'; describe('destructuring and await', () => { it('renders without crashing', () => { const div = document.createElement('div'); - ReactDOM.render(, div); + return new Promise(resolve => { + ReactDOM.render(, div); + }); }); }); diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Generators.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Generators.js index e6a7a115618..67472c3ac93 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Generators.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Generators.js @@ -10,11 +10,7 @@ function * load(limit) { export default class extends Component { static propTypes = { - notifyRendered: PropTypes.func - } - - static defaultProps = { - notifyRendered: () => {} + notifyRendered: PropTypes.func.isRequired } constructor(props) { diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Generators.test.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Generators.test.js index 1fd36cdbed3..8c104d79474 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Generators.test.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Generators.test.js @@ -5,6 +5,8 @@ import Generators from './Generators'; describe('generators', () => { it('renders without crashing', () => { const div = document.createElement('div'); - ReactDOM.render(, div); + return new Promise(resolve => { + ReactDOM.render(, div); + }); }); }); diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectDestructuring.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectDestructuring.js index 21f6d667af2..10fc2876644 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectDestructuring.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectDestructuring.js @@ -11,11 +11,7 @@ function load() { export default class extends Component { static propTypes = { - notifyRendered: PropTypes.func - } - - static defaultProps = { - notifyRendered: () => {} + notifyRendered: PropTypes.func.isRequired } constructor(props) { diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectDestructuring.test.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectDestructuring.test.js index 7ed28147dec..19731a4bc81 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectDestructuring.test.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectDestructuring.test.js @@ -5,6 +5,8 @@ import ObjectDestructuring from './ObjectDestructuring'; describe('object destructuring', () => { it('renders without crashing', () => { const div = document.createElement('div'); - ReactDOM.render(, div); + return new Promise(resolve => { + ReactDOM.render(, div); + }); }); }); diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectSpread.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectSpread.js index 31bcc124d76..2fc49159ec5 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectSpread.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectSpread.js @@ -11,11 +11,7 @@ function load(baseUser) { export default class extends Component { static propTypes = { - notifyRendered: PropTypes.func - } - - static defaultProps = { - notifyRendered: () => {} + notifyRendered: PropTypes.func.isRequired } constructor(props) { diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectSpread.test.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectSpread.test.js index 9de96c26418..856f27edf0a 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectSpread.test.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectSpread.test.js @@ -5,6 +5,8 @@ import ObjectSpread from './ObjectSpread'; describe('object spread', () => { it('renders without crashing', () => { const div = document.createElement('div'); - ReactDOM.render(, div); + return new Promise(resolve => { + ReactDOM.render(, div); + }); }); }); diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Promises.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Promises.js index 00bd434f41f..1dfd8c3563e 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Promises.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Promises.js @@ -11,11 +11,7 @@ function load() { export default class extends Component { static propTypes = { - notifyRendered: PropTypes.func - } - - static defaultProps = { - notifyRendered: () => {} + notifyRendered: PropTypes.func.isRequired } constructor(props) { diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Promises.test.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Promises.test.js index 96b4d298d7c..f8d870b08ef 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Promises.test.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Promises.test.js @@ -5,6 +5,8 @@ import Promises from './Promises'; describe('promises', () => { it('renders without crashing', () => { const div = document.createElement('div'); - ReactDOM.render(, div); + return new Promise(resolve => { + ReactDOM.render(, div); + }); }); }); diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestAndDefault.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestAndDefault.js index 99d2a051612..8bef243e0fe 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestAndDefault.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestAndDefault.js @@ -11,11 +11,7 @@ function load({ id, ...rest } = { id: 0, user: { id: 42, name: '42' } }) { export default class extends Component { static propTypes = { - notifyRendered: PropTypes.func - } - - static defaultProps = { - notifyRendered: () => {} + notifyRendered: PropTypes.func.isRequired } constructor(props) { diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestAndDefault.test.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestAndDefault.test.js index 95f4a19fa0b..a99f2db0797 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestAndDefault.test.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestAndDefault.test.js @@ -5,6 +5,8 @@ import RestAndDefault from './RestAndDefault'; describe('rest + default', () => { it('renders without crashing', () => { const div = document.createElement('div'); - ReactDOM.render(, div); + return new Promise(resolve => { + ReactDOM.render(, div); + }); }); }); diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestParameters.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestParameters.js index 096856b5397..7b150de8a4c 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestParameters.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestParameters.js @@ -11,11 +11,7 @@ function load({ id = 0, ...rest }) { export default class extends Component { static propTypes = { - notifyRendered: PropTypes.func - } - - static defaultProps = { - notifyRendered: () => {} + notifyRendered: PropTypes.func.isRequired } constructor(props) { diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestParameters.test.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestParameters.test.js index 8e097713318..a845aa87be8 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestParameters.test.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestParameters.test.js @@ -5,6 +5,8 @@ import RestParameters from './RestParameters'; describe('rest parameters', () => { it('renders without crashing', () => { const div = document.createElement('div'); - ReactDOM.render(, div); + return new Promise(resolve => { + ReactDOM.render(, div); + }); }); }); diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/TemplateInterpolation.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/TemplateInterpolation.js index 916e271b381..6cb30baa735 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/TemplateInterpolation.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/TemplateInterpolation.js @@ -11,11 +11,7 @@ function load(name) { export default class extends Component { static propTypes = { - notifyRendered: PropTypes.func - } - - static defaultProps = { - notifyRendered: () => {} + notifyRendered: PropTypes.func.isRequired } constructor(props) { diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/TemplateInterpolation.test.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/TemplateInterpolation.test.js index b49af029a44..d9b8db49008 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/TemplateInterpolation.test.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/TemplateInterpolation.test.js @@ -5,6 +5,8 @@ import TemplateInterpolation from './TemplateInterpolation'; describe('template interpolation', () => { it('renders without crashing', () => { const div = document.createElement('div'); - ReactDOM.render(, div); + return new Promise(resolve => { + ReactDOM.render(, div); + }); }); }); From 8834940e0e1300f17e716c67e219c2d4e3ea92bd Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Sat, 4 Feb 2017 15:44:35 -0500 Subject: [PATCH 03/10] Throw for an unknown test --- packages/react-scripts/fixtures/kitchensink/src/App.js | 6 ++---- .../react-scripts/fixtures/kitchensink/src/App.test.js | 8 -------- 2 files changed, 2 insertions(+), 12 deletions(-) delete mode 100644 packages/react-scripts/fixtures/kitchensink/src/App.test.js diff --git a/packages/react-scripts/fixtures/kitchensink/src/App.js b/packages/react-scripts/fixtures/kitchensink/src/App.js index 479f5f38959..75c12c5d7db 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/App.js +++ b/packages/react-scripts/fixtures/kitchensink/src/App.js @@ -114,9 +114,7 @@ class App extends React.Component { case 'unknown-ext-inclusion': require.ensure([], () => this.setFeature(require('./features/webpack/UnknownExtInclusion').default)); break; - default: - this.setFeature(null); - break; + default: throw new Error('Unknown feature!'); } } @@ -129,7 +127,7 @@ class App extends React.Component { if (feature !== null) { return ; } - return null + return null; } } diff --git a/packages/react-scripts/fixtures/kitchensink/src/App.test.js b/packages/react-scripts/fixtures/kitchensink/src/App.test.js deleted file mode 100644 index b84af98d720..00000000000 --- a/packages/react-scripts/fixtures/kitchensink/src/App.test.js +++ /dev/null @@ -1,8 +0,0 @@ -import React from 'react'; -import ReactDOM from 'react-dom'; -import App from './App'; - -it('renders without crashing', () => { - const div = document.createElement('div'); - ReactDOM.render(, div); -}); From b86024145c3a63f3b38e7510428a7a4287d7b7c0 Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Sat, 4 Feb 2017 16:09:55 -0500 Subject: [PATCH 04/10] Naming changes --- packages/react-scripts/fixtures/kitchensink/src/App.js | 8 ++++---- .../fixtures/kitchensink/src/features/env/NodePath.js | 4 ++-- .../kitchensink/src/features/env/NodePath.test.js | 2 +- .../kitchensink/src/features/syntax/ArrayDestructuring.js | 4 ++-- .../src/features/syntax/ArrayDestructuring.test.js | 2 +- .../kitchensink/src/features/syntax/ArraySpread.js | 4 ++-- .../kitchensink/src/features/syntax/ArraySpread.test.js | 2 +- .../kitchensink/src/features/syntax/AsyncAwait.js | 4 ++-- .../kitchensink/src/features/syntax/AsyncAwait.test.js | 2 +- .../kitchensink/src/features/syntax/ClassProperties.js | 4 ++-- .../src/features/syntax/ClassProperties.test.js | 2 +- .../kitchensink/src/features/syntax/ComputedProperties.js | 4 ++-- .../src/features/syntax/ComputedProperties.test.js | 2 +- .../src/features/syntax/CustomInterpolation.js | 4 ++-- .../src/features/syntax/CustomInterpolation.test.js | 2 +- .../kitchensink/src/features/syntax/DefaultParameters.js | 4 ++-- .../src/features/syntax/DefaultParameters.test.js | 2 +- .../src/features/syntax/DestructuringAndAwait.js | 4 ++-- .../src/features/syntax/DestructuringAndAwait.test.js | 2 +- .../kitchensink/src/features/syntax/Generators.js | 4 ++-- .../kitchensink/src/features/syntax/Generators.test.js | 2 +- .../src/features/syntax/ObjectDestructuring.js | 4 ++-- .../src/features/syntax/ObjectDestructuring.test.js | 2 +- .../kitchensink/src/features/syntax/ObjectSpread.js | 4 ++-- .../kitchensink/src/features/syntax/ObjectSpread.test.js | 2 +- .../fixtures/kitchensink/src/features/syntax/Promises.js | 4 ++-- .../kitchensink/src/features/syntax/Promises.test.js | 2 +- .../kitchensink/src/features/syntax/RestAndDefault.js | 4 ++-- .../src/features/syntax/RestAndDefault.test.js | 2 +- .../kitchensink/src/features/syntax/RestParameters.js | 4 ++-- .../src/features/syntax/RestParameters.test.js | 2 +- .../src/features/syntax/TemplateInterpolation.js | 4 ++-- .../src/features/syntax/TemplateInterpolation.test.js | 2 +- 33 files changed, 52 insertions(+), 52 deletions(-) diff --git a/packages/react-scripts/fixtures/kitchensink/src/App.js b/packages/react-scripts/fixtures/kitchensink/src/App.js index 75c12c5d7db..2236c930c33 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/App.js +++ b/packages/react-scripts/fixtures/kitchensink/src/App.js @@ -8,23 +8,23 @@ class BuiltEmitter extends React.Component { componentDidMount() { const { feature } = this.props if (!Component.isPrototypeOf(feature)) { - this.notifyRendered(); + this.handleReady(); } } - notifyRendered() { + handleReady() { document.dispatchEvent(new Event('ReactFeatureDidMount')); } render() { const { props: { feature }, - notifyRendered + handleReady } = this; return (
{createElement(feature, { - notifyRendered + onReady: handleReady })}
); diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/env/NodePath.js b/packages/react-scripts/fixtures/kitchensink/src/features/env/NodePath.js index 5479d3c7ce0..deef80d20ac 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/env/NodePath.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/env/NodePath.js @@ -3,7 +3,7 @@ import load from 'absoluteLoad' export default class extends Component { static propTypes = { - notifyRendered: PropTypes.func.isRequired + onReady: PropTypes.func.isRequired } constructor(props) { @@ -17,7 +17,7 @@ export default class extends Component { } componentDidUpdate() { - this.props.notifyRendered(); + this.props.onReady(); } render() { diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/env/NodePath.test.js b/packages/react-scripts/fixtures/kitchensink/src/features/env/NodePath.test.js index abe62b2f49c..81487d55968 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/env/NodePath.test.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/env/NodePath.test.js @@ -6,7 +6,7 @@ describe('NODE_PATH', () => { it('renders without crashing', () => { const div = document.createElement('div'); return new Promise(resolve => { - ReactDOM.render(, div); + ReactDOM.render(, div); }); }); }); diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArrayDestructuring.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArrayDestructuring.js index 06779c05eee..d07271ed6fc 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArrayDestructuring.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArrayDestructuring.js @@ -11,7 +11,7 @@ function load() { export default class extends Component { static propTypes = { - notifyRendered: PropTypes.func.isRequired + onReady: PropTypes.func.isRequired } constructor(props) { @@ -25,7 +25,7 @@ export default class extends Component { } componentDidUpdate() { - this.props.notifyRendered(); + this.props.onReady(); } render() { diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArrayDestructuring.test.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArrayDestructuring.test.js index 1e636f548c7..05d14263d25 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArrayDestructuring.test.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArrayDestructuring.test.js @@ -6,7 +6,7 @@ describe('array destructuring', () => { it('renders without crashing', () => { const div = document.createElement('div'); return new Promise(resolve => { - ReactDOM.render(, div); + ReactDOM.render(, div); }); }); }); diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArraySpread.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArraySpread.js index e46de969a30..6cb2f6162c4 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArraySpread.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArraySpread.js @@ -11,7 +11,7 @@ function load(users) { export default class extends Component { static propTypes = { - notifyRendered: PropTypes.func.isRequired + onReady: PropTypes.func.isRequired } constructor(props) { @@ -25,7 +25,7 @@ export default class extends Component { } componentDidUpdate() { - this.props.notifyRendered(); + this.props.onReady(); } render() { diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArraySpread.test.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArraySpread.test.js index d905b7295c5..a2191cf1c14 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArraySpread.test.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArraySpread.test.js @@ -6,7 +6,7 @@ describe('array spread', () => { it('renders without crashing', () => { const div = document.createElement('div'); return new Promise(resolve => { - ReactDOM.render(, div); + ReactDOM.render(, div); }); }); }); diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/AsyncAwait.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/AsyncAwait.js index aed435b1cf6..9fe920514a1 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/AsyncAwait.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/AsyncAwait.js @@ -11,7 +11,7 @@ async function load() { export default class extends Component { static propTypes = { - notifyRendered: PropTypes.func.isRequired + onReady: PropTypes.func.isRequired } constructor(props) { @@ -25,7 +25,7 @@ export default class extends Component { } componentDidUpdate() { - this.props.notifyRendered(); + this.props.onReady(); } render() { diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/AsyncAwait.test.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/AsyncAwait.test.js index 279d053a527..bc60c5b58f0 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/AsyncAwait.test.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/AsyncAwait.test.js @@ -6,7 +6,7 @@ describe('async/await', () => { it('renders without crashing', () => { const div = document.createElement('div'); return new Promise(resolve => { - ReactDOM.render(, div); + ReactDOM.render(, div); }); }); }); diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ClassProperties.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ClassProperties.js index 9397aabdca9..726eba1524c 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ClassProperties.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ClassProperties.js @@ -2,7 +2,7 @@ import React, { Component, PropTypes } from 'react' export default class extends Component { static propTypes = { - notifyRendered: PropTypes.func.isRequired + onReady: PropTypes.func.isRequired } users = [ @@ -13,7 +13,7 @@ export default class extends Component { ]; componentDidMount() { - this.props.notifyRendered() + this.props.onReady() } render() { diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ClassProperties.test.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ClassProperties.test.js index 1db9e2ed5d2..898916b2f9a 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ClassProperties.test.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ClassProperties.test.js @@ -6,7 +6,7 @@ describe('class properties', () => { it('renders without crashing', () => { const div = document.createElement('div'); return new Promise(resolve => { - ReactDOM.render(, div); + ReactDOM.render(, div); }); }); }); diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ComputedProperties.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ComputedProperties.js index fa9b22cab7e..04dc7ba109b 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ComputedProperties.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ComputedProperties.js @@ -11,7 +11,7 @@ function load(prefix) { export default class extends Component { static propTypes = { - notifyRendered: PropTypes.func.isRequired + onReady: PropTypes.func.isRequired } constructor(props) { @@ -25,7 +25,7 @@ export default class extends Component { } componentDidUpdate() { - this.props.notifyRendered(); + this.props.onReady(); } render() { diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ComputedProperties.test.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ComputedProperties.test.js index 1c9742d75b0..0aa3d4d7ec6 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ComputedProperties.test.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ComputedProperties.test.js @@ -6,7 +6,7 @@ describe('computed properties', () => { it('renders without crashing', () => { const div = document.createElement('div'); return new Promise(resolve => { - ReactDOM.render(, div); + ReactDOM.render(, div); }); }); }); diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/CustomInterpolation.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/CustomInterpolation.js index 9a505770d08..c80f14dc882 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/CustomInterpolation.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/CustomInterpolation.js @@ -16,7 +16,7 @@ function load() { export default class extends Component { static propTypes = { - notifyRendered: PropTypes.func.isRequired + onReady: PropTypes.func.isRequired } constructor(props) { @@ -30,7 +30,7 @@ export default class extends Component { } componentDidUpdate() { - this.props.notifyRendered(); + this.props.onReady(); } render() { diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/CustomInterpolation.test.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/CustomInterpolation.test.js index 5bc1b2442e8..79af8dc5f6b 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/CustomInterpolation.test.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/CustomInterpolation.test.js @@ -6,7 +6,7 @@ describe('custom interpolation', () => { it('renders without crashing', () => { const div = document.createElement('div'); return new Promise(resolve => { - ReactDOM.render(, div); + ReactDOM.render(, div); }); }); }); diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DefaultParameters.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DefaultParameters.js index 6e0cefc7934..0d7b77d87e3 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DefaultParameters.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DefaultParameters.js @@ -11,7 +11,7 @@ function load(id = 0) { export default class extends Component { static propTypes = { - notifyRendered: PropTypes.func.isRequired + onReady: PropTypes.func.isRequired } constructor(props) { @@ -25,7 +25,7 @@ export default class extends Component { } componentDidUpdate() { - this.props.notifyRendered(); + this.props.onReady(); } render() { diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DefaultParameters.test.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DefaultParameters.test.js index ebb59d715e5..c4a336563ac 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DefaultParameters.test.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DefaultParameters.test.js @@ -6,7 +6,7 @@ describe('default parameters', () => { it('renders without crashing', () => { const div = document.createElement('div'); return new Promise(resolve => { - ReactDOM.render(, div); + ReactDOM.render(, div); }); }); }); diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DestructuringAndAwait.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DestructuringAndAwait.js index 56ff8a31c80..40f51754202 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DestructuringAndAwait.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DestructuringAndAwait.js @@ -11,7 +11,7 @@ async function load() { export default class extends Component { static propTypes = { - notifyRendered: PropTypes.func.isRequired + onReady: PropTypes.func.isRequired } constructor(props) { @@ -25,7 +25,7 @@ export default class extends Component { } componentDidUpdate() { - this.props.notifyRendered(); + this.props.onReady(); } render() { diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DestructuringAndAwait.test.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DestructuringAndAwait.test.js index ab242de3bb8..96b361c742e 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DestructuringAndAwait.test.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DestructuringAndAwait.test.js @@ -6,7 +6,7 @@ describe('destructuring and await', () => { it('renders without crashing', () => { const div = document.createElement('div'); return new Promise(resolve => { - ReactDOM.render(, div); + ReactDOM.render(, div); }); }); }); diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Generators.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Generators.js index 67472c3ac93..6bb64f9103f 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Generators.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Generators.js @@ -10,7 +10,7 @@ function * load(limit) { export default class extends Component { static propTypes = { - notifyRendered: PropTypes.func.isRequired + onReady: PropTypes.func.isRequired } constructor(props) { @@ -27,7 +27,7 @@ export default class extends Component { } componentDidUpdate() { - this.props.notifyRendered(); + this.props.onReady(); } render() { diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Generators.test.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Generators.test.js index 8c104d79474..4e6b8d1d9ad 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Generators.test.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Generators.test.js @@ -6,7 +6,7 @@ describe('generators', () => { it('renders without crashing', () => { const div = document.createElement('div'); return new Promise(resolve => { - ReactDOM.render(, div); + ReactDOM.render(, div); }); }); }); diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectDestructuring.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectDestructuring.js index 10fc2876644..3235a99104c 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectDestructuring.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectDestructuring.js @@ -11,7 +11,7 @@ function load() { export default class extends Component { static propTypes = { - notifyRendered: PropTypes.func.isRequired + onReady: PropTypes.func.isRequired } constructor(props) { @@ -25,7 +25,7 @@ export default class extends Component { } componentDidUpdate() { - this.props.notifyRendered(); + this.props.onReady(); } render() { diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectDestructuring.test.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectDestructuring.test.js index 19731a4bc81..0a21b291bc6 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectDestructuring.test.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectDestructuring.test.js @@ -6,7 +6,7 @@ describe('object destructuring', () => { it('renders without crashing', () => { const div = document.createElement('div'); return new Promise(resolve => { - ReactDOM.render(, div); + ReactDOM.render(, div); }); }); }); diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectSpread.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectSpread.js index 2fc49159ec5..fb43bf8676e 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectSpread.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectSpread.js @@ -11,7 +11,7 @@ function load(baseUser) { export default class extends Component { static propTypes = { - notifyRendered: PropTypes.func.isRequired + onReady: PropTypes.func.isRequired } constructor(props) { @@ -25,7 +25,7 @@ export default class extends Component { } componentDidUpdate() { - this.props.notifyRendered(); + this.props.onReady(); } render() { diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectSpread.test.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectSpread.test.js index 856f27edf0a..4ca5d2b9ab1 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectSpread.test.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectSpread.test.js @@ -6,7 +6,7 @@ describe('object spread', () => { it('renders without crashing', () => { const div = document.createElement('div'); return new Promise(resolve => { - ReactDOM.render(, div); + ReactDOM.render(, div); }); }); }); diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Promises.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Promises.js index 1dfd8c3563e..63f38fed473 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Promises.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Promises.js @@ -11,7 +11,7 @@ function load() { export default class extends Component { static propTypes = { - notifyRendered: PropTypes.func.isRequired + onReady: PropTypes.func.isRequired } constructor(props) { @@ -26,7 +26,7 @@ export default class extends Component { } componentDidUpdate() { - this.props.notifyRendered(); + this.props.onReady(); } render() { diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Promises.test.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Promises.test.js index f8d870b08ef..36c5984a4b5 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Promises.test.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Promises.test.js @@ -6,7 +6,7 @@ describe('promises', () => { it('renders without crashing', () => { const div = document.createElement('div'); return new Promise(resolve => { - ReactDOM.render(, div); + ReactDOM.render(, div); }); }); }); diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestAndDefault.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestAndDefault.js index 8bef243e0fe..7783868ab4d 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestAndDefault.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestAndDefault.js @@ -11,7 +11,7 @@ function load({ id, ...rest } = { id: 0, user: { id: 42, name: '42' } }) { export default class extends Component { static propTypes = { - notifyRendered: PropTypes.func.isRequired + onReady: PropTypes.func.isRequired } constructor(props) { @@ -25,7 +25,7 @@ export default class extends Component { } componentDidUpdate() { - this.props.notifyRendered(); + this.props.onReady(); } render() { diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestAndDefault.test.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestAndDefault.test.js index a99f2db0797..22a91be0847 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestAndDefault.test.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestAndDefault.test.js @@ -6,7 +6,7 @@ describe('rest + default', () => { it('renders without crashing', () => { const div = document.createElement('div'); return new Promise(resolve => { - ReactDOM.render(, div); + ReactDOM.render(, div); }); }); }); diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestParameters.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestParameters.js index 7b150de8a4c..cf216ce01f2 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestParameters.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestParameters.js @@ -11,7 +11,7 @@ function load({ id = 0, ...rest }) { export default class extends Component { static propTypes = { - notifyRendered: PropTypes.func.isRequired + onReady: PropTypes.func.isRequired } constructor(props) { @@ -25,7 +25,7 @@ export default class extends Component { } componentDidUpdate() { - this.props.notifyRendered(); + this.props.onReady(); } render() { diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestParameters.test.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestParameters.test.js index a845aa87be8..f1f8e35e370 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestParameters.test.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestParameters.test.js @@ -6,7 +6,7 @@ describe('rest parameters', () => { it('renders without crashing', () => { const div = document.createElement('div'); return new Promise(resolve => { - ReactDOM.render(, div); + ReactDOM.render(, div); }); }); }); diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/TemplateInterpolation.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/TemplateInterpolation.js index 6cb30baa735..dd6bf49b11d 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/TemplateInterpolation.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/TemplateInterpolation.js @@ -11,7 +11,7 @@ function load(name) { export default class extends Component { static propTypes = { - notifyRendered: PropTypes.func.isRequired + onReady: PropTypes.func.isRequired } constructor(props) { @@ -25,7 +25,7 @@ export default class extends Component { } componentDidUpdate() { - this.props.notifyRendered(); + this.props.onReady(); } render() { diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/TemplateInterpolation.test.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/TemplateInterpolation.test.js index d9b8db49008..41a5fad2c5f 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/TemplateInterpolation.test.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/TemplateInterpolation.test.js @@ -6,7 +6,7 @@ describe('template interpolation', () => { it('renders without crashing', () => { const div = document.createElement('div'); return new Promise(resolve => { - ReactDOM.render(, div); + ReactDOM.render(, div); }); }); }); From 247e5987472b17fe58499f07ede30c8c298674a5 Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Sat, 4 Feb 2017 16:22:53 -0500 Subject: [PATCH 05/10] Add comment --- packages/react-scripts/fixtures/kitchensink/src/App.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/react-scripts/fixtures/kitchensink/src/App.js b/packages/react-scripts/fixtures/kitchensink/src/App.js index 2236c930c33..ad23ef09a00 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/App.js +++ b/packages/react-scripts/fixtures/kitchensink/src/App.js @@ -7,6 +7,9 @@ class BuiltEmitter extends React.Component { componentDidMount() { const { feature } = this.props + + // Class components must call this.props.onReady when they're ready for the test. + // We will assume functional components are ready immediately after mounting. if (!Component.isPrototypeOf(feature)) { this.handleReady(); } From 50b503ea3c31fe86c6c2533c2928ebe6f6e5c7c2 Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Sat, 4 Feb 2017 21:03:38 -0500 Subject: [PATCH 06/10] Use react-app preset --- .../react-scripts/fixtures/kitchensink/.babelrc | 3 +-- .../kitchensink/.template.dependencies.json | 2 -- tasks/e2e-kitchensink.sh | 15 ++++++++++++--- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/packages/react-scripts/fixtures/kitchensink/.babelrc b/packages/react-scripts/fixtures/kitchensink/.babelrc index e2f4ed63f00..c14b2828d16 100644 --- a/packages/react-scripts/fixtures/kitchensink/.babelrc +++ b/packages/react-scripts/fixtures/kitchensink/.babelrc @@ -1,4 +1,3 @@ { - "presets": ["latest"], - "plugins": ["transform-class-properties"] + "presets": ["react-app"] } diff --git a/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json b/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json index 0363856d34b..50511b3d16a 100644 --- a/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json +++ b/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json @@ -1,9 +1,7 @@ { "dependencies": { - "babel-preset-latest": "6.16.0", "babel-register": "6.22.0", "babel-polyfill": "6.20.0", - "babel-plugin-transform-class-properties": "6.22.0", "chai": "3.5.0", "jsdom": "9.8.3", "mocha": "3.2.0" diff --git a/tasks/e2e-kitchensink.sh b/tasks/e2e-kitchensink.sh index 892230ab747..8005f230cc1 100755 --- a/tasks/e2e-kitchensink.sh +++ b/tasks/e2e-kitchensink.sh @@ -110,8 +110,11 @@ create_react_app --scripts-version=$scripts_path --internal-testing-template=$ro # Enter the app directory cd test-kitchensink +# Link to our preset +npm link $root_path/packages/babel-preset-react-app + # Test the build -NODE_PATH=src REACT_APP_SHELL_ENV_MESSAGE=fromtheshell npm run build +NODE_PATH=src NODE_ENV=test REACT_APP_SHELL_ENV_MESSAGE=fromtheshell npm run build # Check for expected output test -e build/*.html test -e build/static/js/main.*.js @@ -120,6 +123,7 @@ test -e build/static/js/main.*.js REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ CI=true \ NODE_PATH=src \ + NODE_ENV=test \ npm test -- --no-cache --testPathPattern="/src/" # Test "development" environment @@ -127,17 +131,20 @@ tmp_server_log=`mktemp` PORT=3001 \ REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ NODE_PATH=src \ + NODE_ENV=development \ nohup npm start &>$tmp_server_log & grep -q 'The app is running at:' <(tail -f $tmp_server_log) E2E_URL="http://localhost:3001" \ REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ CI=true NODE_PATH=src \ + NODE_ENV=development \ node node_modules/.bin/mocha --require babel-register --require babel-polyfill integration/*.test.js # Test "production" environment E2E_FILE=./build/index.html \ CI=true \ NODE_PATH=src \ + NODE_ENV=production \ node_modules/.bin/mocha --require babel-register --require babel-polyfill integration/*.test.js # ****************************************************************************** @@ -153,7 +160,7 @@ npm link $root_path/packages/eslint-config-react-app npm link $root_path/packages/react-dev-utils npm link $root_path/packages/react-scripts -# ...and we need to remove template's .babelrc +# ...and we need to remove template's .babelrc rm .babelrc # Test the build @@ -166,6 +173,7 @@ test -e build/static/js/main.*.js REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ CI=true \ NODE_PATH=src \ + NODE_ENV=test \ npm test -- --no-cache --testPathPattern="/src/" # Test "development" environment @@ -173,12 +181,13 @@ tmp_server_log=`mktemp` PORT=3002 \ REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ NODE_PATH=src \ + NODE_ENV=development \ nohup npm start &>$tmp_server_log & grep -q 'The app is running at:' <(tail -f $tmp_server_log) E2E_URL="http://localhost:3002" \ REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ CI=true NODE_PATH=src \ - NODE_ENV=production \ + NODE_ENV=development \ node_modules/.bin/mocha --require babel-register --require babel-polyfill integration/*.test.js # Test "production" environment From 1835ab6000518c705f056a575297ea1c151c88c0 Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Sun, 5 Feb 2017 12:54:11 -0500 Subject: [PATCH 07/10] Switch out envs --- packages/react-scripts/fixtures/kitchensink/src/App.js | 4 ++-- tasks/e2e-kitchensink.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/react-scripts/fixtures/kitchensink/src/App.js b/packages/react-scripts/fixtures/kitchensink/src/App.js index ad23ef09a00..fa297133f5d 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/App.js +++ b/packages/react-scripts/fixtures/kitchensink/src/App.js @@ -1,6 +1,6 @@ import React, { Component, PropTypes, createElement } from 'react'; -class BuiltEmitter extends React.Component { +class BuiltEmitter extends Component { static propTypes = { feature: PropTypes.func.isRequired } @@ -34,7 +34,7 @@ class BuiltEmitter extends React.Component { } } -class App extends React.Component { +class App extends Component { constructor(props) { super(props); diff --git a/tasks/e2e-kitchensink.sh b/tasks/e2e-kitchensink.sh index 8005f230cc1..bb35923df56 100755 --- a/tasks/e2e-kitchensink.sh +++ b/tasks/e2e-kitchensink.sh @@ -114,7 +114,7 @@ cd test-kitchensink npm link $root_path/packages/babel-preset-react-app # Test the build -NODE_PATH=src NODE_ENV=test REACT_APP_SHELL_ENV_MESSAGE=fromtheshell npm run build +NODE_PATH=src NODE_ENV=production REACT_APP_SHELL_ENV_MESSAGE=fromtheshell npm run build # Check for expected output test -e build/*.html test -e build/static/js/main.*.js @@ -164,7 +164,7 @@ npm link $root_path/packages/react-scripts rm .babelrc # Test the build -NODE_PATH=src REACT_APP_SHELL_ENV_MESSAGE=fromtheshell npm run build +NODE_PATH=src NODE_ENV=production REACT_APP_SHELL_ENV_MESSAGE=fromtheshell npm run build # Check for expected output test -e build/*.html test -e build/static/js/main.*.js From d75c0b124609a163b8015db28c4f746b1b0032c8 Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Sun, 5 Feb 2017 13:05:14 -0500 Subject: [PATCH 08/10] Unlink before eject --- tasks/e2e-kitchensink.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tasks/e2e-kitchensink.sh b/tasks/e2e-kitchensink.sh index bb35923df56..b56a0666aa8 100755 --- a/tasks/e2e-kitchensink.sh +++ b/tasks/e2e-kitchensink.sh @@ -151,6 +151,9 @@ E2E_FILE=./build/index.html \ # Finally, let's check that everything still works after ejecting. # ****************************************************************************** +# Unlink our preset +npm unlink $root_path/packages/babel-preset-react-app + # Eject... echo yes | npm run eject From 73b946cfd522028742a2dd7f67750064c45ff50a Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Mon, 6 Feb 2017 12:17:41 -0500 Subject: [PATCH 09/10] Remove redundant NODE_ENVs --- tasks/e2e-kitchensink.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tasks/e2e-kitchensink.sh b/tasks/e2e-kitchensink.sh index b56a0666aa8..8420458d75f 100755 --- a/tasks/e2e-kitchensink.sh +++ b/tasks/e2e-kitchensink.sh @@ -114,7 +114,7 @@ cd test-kitchensink npm link $root_path/packages/babel-preset-react-app # Test the build -NODE_PATH=src NODE_ENV=production REACT_APP_SHELL_ENV_MESSAGE=fromtheshell npm run build +NODE_PATH=src REACT_APP_SHELL_ENV_MESSAGE=fromtheshell npm run build # Check for expected output test -e build/*.html test -e build/static/js/main.*.js @@ -167,7 +167,7 @@ npm link $root_path/packages/react-scripts rm .babelrc # Test the build -NODE_PATH=src NODE_ENV=production REACT_APP_SHELL_ENV_MESSAGE=fromtheshell npm run build +NODE_PATH=src REACT_APP_SHELL_ENV_MESSAGE=fromtheshell npm run build # Check for expected output test -e build/*.html test -e build/static/js/main.*.js From 082b35b6449492ef8848e37c288850a2debf88d6 Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Mon, 6 Feb 2017 12:23:33 -0500 Subject: [PATCH 10/10] Remove more --- tasks/e2e-kitchensink.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/tasks/e2e-kitchensink.sh b/tasks/e2e-kitchensink.sh index 8420458d75f..c681580b0c7 100755 --- a/tasks/e2e-kitchensink.sh +++ b/tasks/e2e-kitchensink.sh @@ -131,7 +131,6 @@ tmp_server_log=`mktemp` PORT=3001 \ REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ NODE_PATH=src \ - NODE_ENV=development \ nohup npm start &>$tmp_server_log & grep -q 'The app is running at:' <(tail -f $tmp_server_log) E2E_URL="http://localhost:3001" \ @@ -184,7 +183,6 @@ tmp_server_log=`mktemp` PORT=3002 \ REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ NODE_PATH=src \ - NODE_ENV=development \ nohup npm start &>$tmp_server_log & grep -q 'The app is running at:' <(tail -f $tmp_server_log) E2E_URL="http://localhost:3002" \