Best JavaScript code snippet using ava
api.js
Source:api.js
...155 selectedFiles = selectedFiles.sort(this.options.sortTestFiles);156 }157 runStatus = new RunStatus(selectedFiles.length, null, selectionInsights);158 }159 selectedFiles = scheduler.failingTestsFirst(selectedFiles, this._getLocalCacheDir(), this.options.cacheEnabled);160 const debugWithoutSpecificFile = Boolean(this.options.debug) && !this.options.debug.active && selectedFiles.length !== 1;161 await this.emit('run', {162 bailWithoutReporting: debugWithoutSpecificFile,163 clearLogOnNextRun: runtimeOptions.clearLogOnNextRun === true,164 debug: Boolean(this.options.debug),165 failFastEnabled: failFast,166 filePathPrefix: getFilePathPrefix(selectedFiles),167 files: selectedFiles,168 matching: apiOptions.match.length > 0,169 previousFailures: runtimeOptions.previousFailures || 0,170 runOnlyExclusive: runtimeOptions.runOnlyExclusive === true,171 runVector: runtimeOptions.runVector || 0,172 status: runStatus,173 });174 if (setupOrGlobError) {175 throw setupOrGlobError;176 }177 // Bail out early if no files were found, or when debugging and there is not a single specific test file to debug.178 if (selectedFiles.length === 0 || debugWithoutSpecificFile) {179 return runStatus;180 }181 runStatus.on('stateChange', record => {182 if (record.testFile && !timedOutWorkerFiles.has(record.testFile)) {183 // Debounce the timer whenever there is activity from workers that184 // haven't already timed out.185 timeoutTrigger.debounce();186 }187 if (failFast && (record.type === 'hook-failed' || record.type === 'test-failed' || record.type === 'worker-failed')) {188 // Prevent new test files from running once a test has failed.189 bailed = true;190 // Try to stop currently scheduled tests.191 for (const worker of pendingWorkers) {192 worker.notifyOfPeerFailure();193 }194 }195 });196 const providerStates = [];197 await Promise.all(providers.map(async ({type, main}) => {198 const state = await main.compile({cacheDir: this._createCacheDir(), files: testFiles});199 if (state !== null) {200 providerStates.push({type, state});201 }202 }));203 // Resolve the correct concurrency value.204 let concurrency = Math.min(os.cpus().length, isCi ? 2 : Number.POSITIVE_INFINITY);205 if (apiOptions.concurrency > 0) {206 concurrency = apiOptions.concurrency;207 }208 if (apiOptions.serial) {209 concurrency = 1;210 }211 const deregisteredSharedWorkers = [];212 // Try and run each file, limited by `concurrency`.213 await pMap(selectedFiles, async file => {214 // No new files should be run once a test has timed out or failed,215 // and failFast is enabled.216 if (bailed) {217 return;218 }219 const lineNumbers = getApplicableLineNumbers(globs.normalizeFileForMatching(apiOptions.projectDir, file), filter);220 // Removing `providers` and `sortTestFiles` fields because they cannot be transferred to the worker threads.221 const {providers, sortTestFiles, ...forkOptions} = apiOptions;222 const options = {223 ...forkOptions,224 providerStates,225 lineNumbers,226 recordNewSnapshots: !isCi,227 // If we're looking for matches, run every single test process in exclusive-only mode228 runOnlyExclusive: apiOptions.match.length > 0 || runtimeOptions.runOnlyExclusive === true,229 };230 if (runtimeOptions.updateSnapshots) {231 // Don't use in Object.assign() since it'll override options.updateSnapshots even when false.232 options.updateSnapshots = true;233 }234 const worker = fork(file, options, apiOptions.nodeArguments);235 worker.onStateChange(data => {236 if (data.type === 'test-timeout-configured' && !apiOptions.debug) {237 timeoutTrigger.ignoreFor(data.period);238 }239 });240 runStatus.observeWorker(worker, file, {selectingLines: lineNumbers.length > 0});241 deregisteredSharedWorkers.push(observeWorkerProcess(worker, runStatus));242 pendingWorkers.add(worker);243 worker.promise.then(() => {244 pendingWorkers.delete(worker);245 });246 timeoutTrigger.debounce();247 await worker.promise;248 }, {concurrency, stopOnError: false});249 // Allow shared workers to clean up before the run ends.250 await Promise.all(deregisteredSharedWorkers);251 scheduler.storeFailedTestFiles(runStatus, this.options.cacheEnabled === false ? null : this._createCacheDir());252 } catch (error) {253 if (error && error.name === 'AggregateError') {254 for (const error_ of error.errors) {255 runStatus.emitStateChange({type: 'internal-error', err: serializeError('Internal error', false, error_)});256 }257 } else {258 runStatus.emitStateChange({type: 'internal-error', err: serializeError('Internal error', false, error)});259 }260 }261 timeoutTrigger.discard();262 return runStatus;263 }264 _getLocalCacheDir() {265 return path.join(this.options.projectDir, 'node_modules', '.cache', 'ava');266 }267 _createCacheDir() {268 if (this._cacheDir) {269 return this._cacheDir;270 }271 const cacheDir = this.options.cacheEnabled === false272 ? fs.mkdtempSync(`${tempDir}${path.sep}`)273 : this._getLocalCacheDir();274 // Ensure cacheDir exists275 fs.mkdirSync(cacheDir, {recursive: true});276 this._cacheDir = cacheDir;277 return cacheDir;278 }...
Using AI Code Generation
1var avalon = require('avalon');2avalon._getLocalCacheDir();3var avalon = require('avalon');4avalon._getLocalCacheDir();5var avalon = require('avalon');6avalon._getLocalCacheDir();7var avalon = require('avalon');8avalon._getLocalCacheDir();9var avalon = require('avalon');10avalon._getLocalCacheDir();11var avalon = require('avalon');12avalon._getLocalCacheDir();13var avalon = require('avalon');14avalon._getLocalCacheDir();15var avalon = require('avalon');16avalon._getLocalCacheDir();17var avalon = require('avalon');18avalon._getLocalCacheDir();19var avalon = require('avalon');20avalon._getLocalCacheDir();21var avalon = require('avalon');22avalon._getLocalCacheDir();23var avalon = require('avalon');24avalon._getLocalCacheDir();25var avalon = require('avalon');26avalon._getLocalCacheDir();
Using AI Code Generation
1var avalon = require('avalon');2var localCacheDir = avalon._getLocalCacheDir();3console.log(localCacheDir);4var avalon = require('avalon');5var localCacheDir = avalon._getLocalCacheDir();6console.log(localCacheDir);7var avalon = require('avalon');8var localCacheDir = avalon._getLocalCacheDir();9console.log(localCacheDir);10var avalon = require('avalon');11var localCacheDir = avalon._getLocalCacheDir();12console.log(localCacheDir);13var avalon = require('avalon');14var localCacheDir = avalon._getLocalCacheDir();15console.log(localCacheDir);16var avalon = require('avalon');17var localCacheDir = avalon._getLocalCacheDir();18console.log(localCacheDir);19var avalon = require('avalon');20var localCacheDir = avalon._getLocalCacheDir();21console.log(localCacheDir);22var avalon = require('avalon');23var localCacheDir = avalon._getLocalCacheDir();24console.log(localCacheDir);25var avalon = require('avalon');26var localCacheDir = avalon._getLocalCacheDir();27console.log(localCacheDir);28var avalon = require('avalon');29var localCacheDir = avalon._getLocalCacheDir();30console.log(localCacheDir);31var avalon = require('avalon');
Using AI Code Generation
1var available = require('available');2var localCacheDir = available._getLocalCacheDir();3var available = require('available');4var localCacheDir = available._getLocalCacheDir();5var available = require('available');6var localCacheDir = available._getLocalCacheDir();7var available = require('available');8var localCacheDir = available._getLocalCacheDir();9var available = require('available');10var localCacheDir = available._getLocalCacheDir();11var available = require('available');12var localCacheDir = available._getLocalCacheDir();13var available = require('available');14var localCacheDir = available._getLocalCacheDir();15var available = require('available');16var localCacheDir = available._getLocalCacheDir();17var available = require('available');18var localCacheDir = available._getLocalCacheDir();19var available = require('available');20var localCacheDir = available._getLocalCacheDir();21var available = require('available');22var localCacheDir = available._getLocalCacheDir();23var available = require('available');24var localCacheDir = available._getLocalCacheDir();25var available = require('available');26var localCacheDir = available._getLocalCacheDir();
Using AI Code Generation
1var cacheDir = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, '_getLocalCacheDir');2if (!cacheDir.exists()) {3 cacheDir.createDirectory();4}5var cacheDir = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, '_getLocalCacheDir');6if (!cacheDir.exists()) {7 cacheDir.createDirectory();8}
Using AI Code Generation
1var avatar = require('avatar');2var cacheDir = avatar._getLocalCacheDir();3console.log('cacheDir: ' + cacheDir);4var avatar = require('avatar');5var cacheDir = avatar._getLocalCacheDir();6console.log('cacheDir: ' + cacheDir);7var avatar = require('avatar');8var cacheDir = avatar._getLocalCacheDir();9console.log('cacheDir: ' + cacheDir);10var avatar = require('avatar');11var cacheDir = avatar._getLocalCacheDir();12console.log('cacheDir: ' + cacheDir);13var avatar = require('avatar');14var cacheDir = avatar._getLocalCacheDir();15console.log('cacheDir: ' + cacheDir);16var avatar = require('avatar');17var cacheDir = avatar._getLocalCacheDir();18console.log('cacheDir: ' + cacheDir);19var avatar = require('avatar');20var cacheDir = avatar._getLocalCacheDir();21console.log('cacheDir: ' + cacheDir);22var avatar = require('avatar');23var cacheDir = avatar._getLocalCacheDir();24console.log('cacheDir: ' + cacheDir);25var avatar = require('avatar');26var cacheDir = avatar._getLocalCacheDir();27console.log('cacheDir: ' + cacheDir);28var avatar = require('avatar');29var cacheDir = avatar._getLocalCacheDir();30console.log('cacheDir: ' + cacheDir);31var avatar = require('avatar');
Using AI Code Generation
1var available = require('available');2var localCacheDir = available._getLocalCacheDir();3Ti.API.info('Local cache directory: ' + localCacheDir);4var remoteCacheDir = available._getRemoteCacheDir();5Ti.API.info('Remote cache directory: ' + remoteCacheDir);6var remoteCacheDir = available._getRemoteCacheDir();7Ti.API.info('Remote cache directory: ' + remoteCacheDir);8var remoteCacheDir = available._getRemoteCacheDir();9Ti.API.info('Remote cache directory: ' + remoteCacheDir);10var remoteCacheDir = available._getRemoteCacheDir();11Ti.API.info('Remote cache directory: ' + remoteCacheDir);12var remoteCacheDir = available._getRemoteCacheDir();13Ti.API.info('Remote cache directory: ' + remoteCacheDir);14var remoteCacheDir = available._getRemoteCacheDir();15Ti.API.info('Remote cache directory: ' + remoteCacheDir);16var remoteCacheDir = available._getRemoteCacheDir();17Ti.API.info('Remote cache directory: ' + remoteCacheDir);18var remoteCacheDir = available._getRemoteCacheDir();19Ti.API.info('Remote cache directory: ' + remoteCacheDir);20var remoteCacheDir = available._getRemoteCacheDir();21Ti.API.info('Remote cache directory: ' + remoteCacheDir);22var remoteCacheDir = available._getRemoteCacheDir();23Ti.API.info('Remote cache directory: ' + remoteCacheDir);24var remoteCacheDir = available._getRemoteCacheDir();25Ti.API.info('Remote cache directory: ' + remoteCacheDir);
Using AI Code Generation
1var available = require('available');2var cacheDir = available._getLocalCacheDir();3Ti.API.info('Cache dir: ' + cacheDir);4dependencies {5}6var available = require('available');7var cacheDir = available._getLocalCacheDir();8Ti.API.info('Cache dir: ' + cacheDir);9dependencies {10}11var available = require('available');12var cacheDir = available._getLocalCacheDir();13Ti.API.info('Cache dir: ' + cacheDir);14dependencies {15}16var available = require('available');17var cacheDir = available._getLocalCacheDir();18Ti.API.info('Cache dir: ' + cacheDir);19dependencies {
Using AI Code Generation
1var cacheDir = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, 'LocalCache');2if (cacheDir.exists() == false) {3 cacheDir.createDirectory();4}5var file = Ti.Filesystem.getFile(cacheDir, 'test.txt');6file.write('test');7var cacheDir = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, 'LocalCache');8if (cacheDir.exists() == false) {9 cacheDir.createDirectory();10}11var file = Ti.Filesystem.getFile(cacheDir, 'test.txt');12file.write('test');
Using AI Code Generation
1var cacheDir = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, "localCache");2if (!cacheDir.exists()) {3 cacheDir.createDirectory();4}5var cacheDir = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, "localCache");6if (!cacheDir.exists()) {7 cacheDir.createDirectory();8}
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!