Skip to content

Commit

Permalink
add test case for ordering to list-tests e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
jeysal committed Jan 10, 2019
1 parent 16a683a commit 350e12a
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
5 changes: 3 additions & 2 deletions e2e/__tests__/__snapshots__/listTests.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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\\"]"`;
10 changes: 10 additions & 0 deletions e2e/__tests__/listTests.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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']);

Expand Down
3 changes: 3 additions & 0 deletions e2e/list-tests/__tests__/other.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
15 changes: 15 additions & 0 deletions e2e/list-tests/__tests__/with-dep.test.js
Original file line number Diff line number Diff line change
@@ -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);
});

0 comments on commit 350e12a

Please sign in to comment.