-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add option testSequencer
allow user use custom sequencer.
#8223
Changes from all commits
cac8a66
27b7eba
4b12436
aeea6ad
5093f46
b94e545
ca3305e
b5c593a
9223489
ec029bb
02f14fa
46ef8f0
30ac7e5
4bc5a01
409a9ba
abc58e2
934f77c
1b3f0ef
35b2177
f8b9b17
4efe85c
20910a9
2e8fe7b
7d58433
9662a12
7e8d15a
0866aba
5ffb812
745cad3
301a5cd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* 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. | ||
*/ | ||
|
||
import path from 'path'; | ||
import runJest from '../runJest'; | ||
import {extractSummary} from '../Utils'; | ||
const dir = path.resolve(__dirname, '../custom-test-sequencer'); | ||
|
||
test('run prioritySequence first', () => { | ||
const result = runJest(dir, ['-i']); | ||
expect(result.status).toBe(0); | ||
const sequence = extractSummary(result.stderr) | ||
.rest.replace(/PASS /g, '') | ||
.split('\n'); | ||
expect(sequence).toEqual([ | ||
'./a.test.js', | ||
'./b.test.js', | ||
'./c.test.js', | ||
'./d.test.js', | ||
'./e.test.js', | ||
]); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/** | ||
* 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. | ||
*/ | ||
test('a', () => {}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/** | ||
* 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. | ||
*/ | ||
test('b', () => {}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/** | ||
* 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. | ||
*/ | ||
test('c', () => {}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/** | ||
* 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. | ||
*/ | ||
test('d', () => {}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/** | ||
* 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. | ||
*/ | ||
test('e', () => {}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"jest": { | ||
"testEnvironment": "node", | ||
"testSequencer": "<rootDir>/testSequencer.js" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* 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. | ||
*/ | ||
|
||
const Sequencer = require('@jest/test-sequencer').default; | ||
|
||
class CustomSequencer extends Sequencer { | ||
sort(tests) { | ||
SimenB marked this conversation as resolved.
Show resolved
Hide resolved
WeiAnAn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const copyTests = Array.from(tests); | ||
return copyTests.sort((testA, testB) => (testA.path > testB.path ? 1 : -1)); | ||
} | ||
} | ||
|
||
module.exports = CustomSequencer; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,6 +71,7 @@ const defaultOptions: Config.DefaultOptions = { | |
testRegex: [], | ||
testResultsProcessor: null, | ||
testRunner: 'jasmine2', | ||
testSequencer: '@jest/test-sequencer', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This value doesn't get fully resolved unless explicitly set, so it cannot work with PnP. It should be done like here: https://github.com/WeiAnAn/jest/blob/301a5cda50bf82617fe776938ee3fbd1c24b4a7c/packages/jest-config/src/normalize.ts#L477-L479 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We resolve it in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm checking, but I think it only get resolved when the |
||
testURL: 'http://localhost', | ||
timers: 'real', | ||
transform: null, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
**/__mocks__/** | ||
**/__tests__/** | ||
src |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"name": "@jest/test-sequencer", | ||
"version": "24.6.0", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/facebook/jest.git", | ||
"directory": "packages/test-sequencer" | ||
}, | ||
"license": "MIT", | ||
"main": "build/index.js", | ||
"types": "build/index.d.ts", | ||
"dependencies": { | ||
"@jest/test-result": "^24.6.0", | ||
"jest-haste-map": "^24.6.0", | ||
"jest-runner": "^24.6.0", | ||
"jest-runtime": "^24.6.0" | ||
}, | ||
"engines": { | ||
"node": ">= 6" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"gitHead": "800533020f5b2f153615c821ed7cb12fd868fa6f" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"rootDir": "src", | ||
"outDir": "build" | ||
}, | ||
"references": [ | ||
{"path": "../jest-haste-map"}, | ||
{"path": "../jest-runner"}, | ||
{"path": "../jest-test-result"}, | ||
{"path": "../jest-types"} | ||
] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could do
import Sequencer from '@jest/test-sequencer';
instead to avoid the.default
part. Fine as-is though