Skip to content

Commit 2920417

Browse files
committed
add test case for ordering to list-tests e2e test
1 parent 1ca41b5 commit 2920417

File tree

4 files changed

+30
-1
lines changed

4 files changed

+30
-1
lines changed

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
exports[`--listTests flag causes tests to be printed in different lines 1`] = `
44
/MOCK_ABOLUTE_PATH/e2e/list-tests/__tests__/dummy.test.js
55
/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__/listTests.test.js

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

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

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) Facebook, Inc. and its affiliates. 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)