Skip to content

Commit 9adb791

Browse files
committed
add test case for ordering to list-tests e2e test
1 parent 0a7e811 commit 9adb791

File tree

4 files changed

+31
-2
lines changed

4 files changed

+31
-2
lines changed

e2e/__tests__/__snapshots__/list_tests.test.js.snap

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
exports[`--listTests flag causes tests to be printed in different lines 1`] = `
44
"/MOCK_ABOLUTE_PATH/e2e/list-tests/__tests__/dummy.test.js
5-
/MOCK_ABOLUTE_PATH/e2e/list-tests/__tests__/other.test.js"
5+
/MOCK_ABOLUTE_PATH/e2e/list-tests/__tests__/other.test.js
6+
/MOCK_ABOLUTE_PATH/e2e/list-tests/__tests__/with-dep.test.js"
67
`;
78

8-
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\\"]"`;
9+
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\\"]"`;

e2e/__tests__/list_tests.test.js

+10
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,16 @@ describe('--listTests flag', () => {
3333
).toMatchSnapshot();
3434
});
3535

36+
it('prints tests in the execution order determined by their dependency sizes', () => {
37+
const {status, stdout} = runJest('list-tests', ['--listTests']);
38+
expect(status).toBe(0);
39+
expect(normalizePaths(stdout).split('\n')).toEqual([
40+
expect.stringContaining('/with-dep.test.js'),
41+
expect.stringContaining('/other.test.js'),
42+
expect.stringContaining('/dummy.test.js'),
43+
]);
44+
});
45+
3646
it('causes tests to be printed out as JSON when using the --json flag', () => {
3747
const {status, stdout} = runJest('list-tests', ['--listTests', '--json']);
3848

e2e/list-tests/__tests__/other.test.js

+3
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ it("isn't actually run", () => {
1111
// (because it is only used for --listTests)
1212
expect(true).toBe(false);
1313
});
14+
15+
// Because of this comment, other.test.js is slightly larger than dummy.test.js.
16+
// This matters for the order in which tests are sequenced.
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* Copyright (c) 2018-present, Facebook, Inc. All rights reserved.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
'use strict';
9+
10+
require('./dummy.test.js');
11+
12+
it("isn't actually run", () => {
13+
// (because it is only used for --listTests)
14+
expect(true).toBe(false);
15+
});

0 commit comments

Comments
 (0)