prepack/test/react/FirstRenderOnly-test.js
Dan Abramov 5159b0d832 Make React tests fast (#2187)
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
2018-07-02 11:25:58 -07:00

97 lines
3.1 KiB
JavaScript

/**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
/* @flow */
const setupReactTests = require("./setupReactTests");
const { runTest } = setupReactTests();
/* eslint-disable no-undef */
const { it } = global;
it("Simple", () => {
runTest(__dirname + "/FirstRenderOnly/simple.js", { firstRenderOnly: true });
});
it("Simple #2", () => {
runTest(__dirname + "/FirstRenderOnly/simple-2.js", { firstRenderOnly: true });
});
it("Simple #3", () => {
runTest(__dirname + "/FirstRenderOnly/simple-3.js", { firstRenderOnly: true });
});
// Should be refined in a follow up PR to check for
// functions and keys on deep referenced objects linking
// to host components
it("Simple #4", () => {
runTest(__dirname + "/FirstRenderOnly/simple-4.js", { firstRenderOnly: true });
});
it("componentWillMount", () => {
runTest(__dirname + "/FirstRenderOnly/will-mount.js", { firstRenderOnly: true });
});
it("getDerivedStateFromProps", () => {
runTest(__dirname + "/FirstRenderOnly/get-derived-state-from-props.js", { firstRenderOnly: true });
});
it("getDerivedStateFromProps 2", () => {
runTest(__dirname + "/FirstRenderOnly/get-derived-state-from-props2.js", { firstRenderOnly: true });
});
it("getDerivedStateFromProps 3", () => {
runTest(__dirname + "/FirstRenderOnly/get-derived-state-from-props3.js", { firstRenderOnly: true });
});
it("getDerivedStateFromProps 4", () => {
runTest(__dirname + "/FirstRenderOnly/get-derived-state-from-props4.js", { firstRenderOnly: true });
});
it("getDerivedStateFromProps 5", () => {
runTest(__dirname + "/FirstRenderOnly/get-derived-state-from-props5.js", { firstRenderOnly: true });
});
it("React Context", () => {
runTest(__dirname + "/FirstRenderOnly/react-context.js", { firstRenderOnly: true });
});
it("React Context 2", () => {
runTest(__dirname + "/FirstRenderOnly/react-context2.js", { firstRenderOnly: true });
});
it("React Context 3", () => {
runTest(__dirname + "/FirstRenderOnly/react-context3.js", { firstRenderOnly: true });
});
it("React Context 4", () => {
runTest(__dirname + "/FirstRenderOnly/react-context4.js", { firstRenderOnly: true });
});
it("React Context 5", () => {
runTest(__dirname + "/FirstRenderOnly/react-context5.js", { firstRenderOnly: true });
});
it("React Context 6", () => {
runTest(__dirname + "/FirstRenderOnly/react-context6.js", { firstRenderOnly: true });
});
// Known to be broken due to incomplete arrow function support.
it.skip("Replace this in callbacks", () => {
runTest(__dirname + "/FirstRenderOnly/replace-this-in-callbacks.js", { firstRenderOnly: true });
});
it("Replace this in callbacks 2", () => {
runTest(__dirname + "/FirstRenderOnly/replace-this-in-callbacks2.js", { firstRenderOnly: true });
});
it("Replace this in callbacks 3", () => {
runTest(__dirname + "/FirstRenderOnly/replace-this-in-callbacks3.js", { firstRenderOnly: true });
});