Skip to content

Commit 23b9679

Browse files
chadius-maximusNicholas Pape
authored andcommitted
Additional jest task arguments; ability to choose between default and passed args (microsoft#459)
* added two optional parameters to jest task config; default task values are only used if the optional values aren't passed in * rush change update
1 parent 603ce73 commit 23b9679

6 files changed

Lines changed: 43 additions & 2 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@microsoft/gulp-core-build",
5+
"comment": "Added optional args moduleDirectories and rootDir to JestTask",
6+
"type": "minor"
7+
}
8+
],
9+
"packageName": "@microsoft/gulp-core-build",
10+
"email": "olfilato@users.noreply.github.com"
11+
}

‎common/reviews/api/gulp-core-build.api.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,8 @@ interface IJestConfig {
196196
coverage?: boolean;
197197
coverageReporters?: string[];
198198
isEnabled?: boolean;
199+
moduleDirectories?: string[];
200+
rootDir?: string;
199201
testPathIgnorePatterns?: string[];
200202
}
201203

‎common/reviews/api/node-library-build.api.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@ interface IJestConfig {
188188
coverage?: boolean;
189189
coverageReporters?: string[];
190190
isEnabled?: boolean;
191+
moduleDirectories?: string[];
192+
rootDir?: string;
191193
testPathIgnorePatterns?: string[];
192194
}
193195

‎common/reviews/api/web-library-build.api.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@ interface IJestConfig {
188188
coverage?: boolean;
189189
coverageReporters?: string[];
190190
isEnabled?: boolean;
191+
moduleDirectories?: string[];
192+
rootDir?: string;
191193
testPathIgnorePatterns?: string[];
192194
}
193195

‎core-build/gulp-core-build/src/tasks/JestTask.ts‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,16 @@ export interface IJestConfig {
4747
* Same as Jest CLI option testPathIgnorePatterns
4848
*/
4949
testPathIgnorePatterns?: string[];
50+
51+
/**
52+
* Same as Jest CLI option moduleDirectories
53+
*/
54+
moduleDirectories?: string[];
55+
56+
/**
57+
* Same as Jest CLI option rootDir
58+
*/
59+
rootDir?: string;
5060
}
5161

5262
const DEFAULT_JEST_CONFIG_FILE_NAME: string = 'jest.config.json';
@@ -113,9 +123,12 @@ export class JestTask extends GulpTask<IJestConfig> {
113123
coverageReporters: this.taskConfig.coverageReporters,
114124
coverageDirectory: path.join(this.buildConfig.tempFolder, 'coverage'),
115125
maxWorkers: 1,
116-
moduleDirectories: ['node_modules', this.buildConfig.libFolder],
126+
moduleDirectories: !!this.taskConfig.moduleDirectories ?
127+
this.taskConfig.moduleDirectories :
128+
['node_modules', this.buildConfig.libFolder],
117129
reporters: [path.join(__dirname, 'JestReporter.js')],
118-
rootDir: this.buildConfig.rootPath,
130+
rootDir: !!this.taskConfig.rootDir ?
131+
this.taskConfig.rootDir : this.buildConfig.rootPath,
119132
runInBand: true,
120133
testMatch: ['**/*.test.js?(x)'],
121134
testPathIgnorePatterns: this.taskConfig.testPathIgnorePatterns,

‎core-build/gulp-core-build/src/tasks/jest.schema.json‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,17 @@
4646
"items": {
4747
"type": "string"
4848
}
49+
},
50+
"moduleDirectories": {
51+
"description": "Same as Jest CLI option moduleDirectories",
52+
"type": "array",
53+
"items": {
54+
"type": "string"
55+
}
56+
},
57+
"rootDir": {
58+
"description": "Same as Jest CLI option rootDir",
59+
"type": "string"
4960
}
5061
},
5162
"additionalProperties": false

0 commit comments

Comments
 (0)