diff --git a/e2e/__tests__/__snapshots__/list_tests.test.js.snap b/e2e/__tests__/__snapshots__/list_tests.test.js.snap index b1d8584f771e..73f79aa25de4 100644 --- a/e2e/__tests__/__snapshots__/list_tests.test.js.snap +++ b/e2e/__tests__/__snapshots__/list_tests.test.js.snap @@ -2,7 +2,8 @@ exports[`--listTests flag causes tests to be printed in different lines 1`] = ` "/MOCK_ABOLUTE_PATH/e2e/list-tests/__tests__/dummy.test.js -/MOCK_ABOLUTE_PATH/e2e/list-tests/__tests__/other.test.js" +/MOCK_ABOLUTE_PATH/e2e/list-tests/__tests__/other.test.js +/MOCK_ABOLUTE_PATH/e2e/list-tests/__tests__/with-dep.test.js" `; -exports[`--listTests flag causes tests to be printed out as JSON when using the --json flag 1`] = `"[\\"/MOCK_ABOLUTE_PATH/e2e/list-tests/__tests__/dummy.test.js\\",\\"/MOCK_ABOLUTE_PATH/e2e/list-tests/__tests__/other.test.js\\"]"`; +exports[`--listTests flag causes tests to be printed out as JSON when using the --json flag 1`] = `"[\\"/MOCK_ABOLUTE_PATH/e2e/list-tests/__tests__/dummy.test.js\\",\\"/MOCK_ABOLUTE_PATH/e2e/list-tests/__tests__/other.test.js\\",\\"/MOCK_ABOLUTE_PATH/e2e/list-tests/__tests__/with-dep.test.js\\"]"`; diff --git a/e2e/__tests__/list_tests.test.js b/e2e/__tests__/list_tests.test.js index 641d3ed5bc9f..9de9cd89a408 100644 --- a/e2e/__tests__/list_tests.test.js +++ b/e2e/__tests__/list_tests.test.js @@ -33,6 +33,16 @@ describe('--listTests flag', () => { ).toMatchSnapshot(); }); + it('prints tests in the execution order determined by their dependency sizes', () => { + const {status, stdout} = runJest('list-tests', ['--listTests']); + expect(status).toBe(0); + expect(normalizePaths(stdout).split('\n')).toEqual([ + expect.stringContaining('/with-dep.test.js'), + expect.stringContaining('/other.test.js'), + expect.stringContaining('/dummy.test.js'), + ]); + }); + it('causes tests to be printed out as JSON when using the --json flag', () => { const {status, stdout} = runJest('list-tests', ['--listTests', '--json']); diff --git a/e2e/list-tests/__tests__/other.test.js b/e2e/list-tests/__tests__/other.test.js index cfc1ee266fb4..2607de475730 100644 --- a/e2e/list-tests/__tests__/other.test.js +++ b/e2e/list-tests/__tests__/other.test.js @@ -11,3 +11,6 @@ it("isn't actually run", () => { // (because it is only used for --listTests) expect(true).toBe(false); }); + +// Because of this comment, other.test.js is slightly larger than dummy.test.js. +// This matters for the order in which tests are sequenced. diff --git a/e2e/list-tests/__tests__/with-dep.test.js b/e2e/list-tests/__tests__/with-dep.test.js new file mode 100644 index 000000000000..15648e892ab6 --- /dev/null +++ b/e2e/list-tests/__tests__/with-dep.test.js @@ -0,0 +1,15 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +'use strict'; + +require('./dummy.test.js'); + +it("isn't actually run", () => { + // (because it is only used for --listTests) + expect(true).toBe(false); +});