MCPcopy Index your code
hub / github.com/codeceptjs/CodeceptJS / loadTests

Method loadTests

lib/codecept.js:174–224  ·  view source on GitHub ↗

* Loads tests by pattern or by config.tests * * @param {string} [pattern]

(pattern)

Source from the content-addressed store, hash-verified

172 * @param {string} [pattern]
173 */
174 loadTests(pattern) {
175 const options = {
176 cwd: store.codeceptDir,
177 }
178
179 let patterns = [pattern]
180 if (!pattern) {
181 patterns = []
182
183 // If the user wants to test a specific set of test files as an array or string.
184 if (this.config.tests && !this.opts.features) {
185 if (Array.isArray(this.config.tests)) {
186 patterns.push(...this.config.tests)
187 } else {
188 patterns.push(this.config.tests)
189 }
190 }
191
192 if (this.config.gherkin && this.config.gherkin.features && !this.opts.tests) {
193 if (Array.isArray(this.config.gherkin.features)) {
194 this.config.gherkin.features.forEach(feature => {
195 patterns.push(feature)
196 })
197 } else {
198 patterns.push(this.config.gherkin.features)
199 }
200 }
201 }
202
203 for (pattern of patterns) {
204 if (pattern) {
205 globSync(pattern, options).forEach(file => {
206 if (file.includes('node_modules')) return
207 if (!fsPath.isAbsolute(file)) {
208 file = fsPath.join(store.codeceptDir, file)
209 }
210 if (!this.testFiles.includes(fsPath.resolve(file))) {
211 this.testFiles.push(fsPath.resolve(file))
212 }
213 })
214 }
215 }
216
217 if (this.opts.shuffle) {
218 this.testFiles = shuffle(this.testFiles)
219 }
220
221 if (this.opts.shard) {
222 this.testFiles = this._applySharding(this.testFiles, this.opts.shard)
223 }
224 }
225
226 /**
227 * Apply sharding to test files based on shard configuration

Callers 9

initializeCodeceptFunction · 0.95
run.jsFile · 0.80
dryRun.jsFile · 0.80
run-rerun.jsFile · 0.80
check.jsFile · 0.80
runTests.jsFile · 0.80
shard_test.jsFile · 0.80
mcp-server.jsFile · 0.80

Calls 3

_applyShardingMethod · 0.95
pushMethod · 0.80
includesMethod · 0.80

Tested by

no test coverage detected