jasmine
Advanced tools
Comparing version 5.0.0-alpha.1 to 5.0.0-beta.0
@@ -5,3 +5,6 @@ const cluster = require('node:cluster'); | ||
const loader = new Loader(); | ||
new ParallelWorker({loader, clusterWorker: cluster.worker}); | ||
new ParallelWorker({ | ||
loader: new Loader(), | ||
process, | ||
clusterWorker: cluster.worker | ||
}); |
const path = require('path'); | ||
const fs = require('fs'); | ||
const os = require('os'); | ||
const unWindows = require('./unWindows'); | ||
@@ -117,5 +118,11 @@ | ||
} else if (arg.match("^--parallel=(.*)")) { | ||
numWorkers = parseFloat(arg.match("^--parallel=(.*)")[1]); | ||
if (isNaN(numWorkers) || numWorkers < 2 || numWorkers !== Math.floor(numWorkers)) { | ||
usageErrors.push('Argument to --parallel= must be an integer greater than 1'); | ||
const w = arg.match("^--parallel=(.*)")[1]; | ||
if (w === 'auto') { | ||
// A reasonable default in most situations | ||
numWorkers = os.cpus().length -1; | ||
} else { | ||
numWorkers = parseFloat(w); | ||
if (isNaN(numWorkers) || numWorkers < 2 || numWorkers !== Math.floor(numWorkers)) { | ||
usageErrors.push('Argument to --parallel= must be an integer greater than 1'); | ||
} | ||
} | ||
@@ -295,2 +302,3 @@ } else if (arg === '--') { | ||
print('%s\tRun in parallel with N workers', lPad('--parallel=N', 18)); | ||
print('%s\tRun in parallel with an automatically chosen number of workers', lPad('--parallel=auto', 18)); | ||
print('%s\tturn off color in spec output', lPad('--no-color', 18)); | ||
@@ -297,0 +305,0 @@ print('%s\tforce turn on color in spec output', lPad('--color', 18)); |
@@ -24,2 +24,13 @@ const path = require('path'); | ||
*/ | ||
/** | ||
* Whether to create the globals (describe, it, etc) that make up Jasmine's | ||
* spec-writing interface. If it is set to false, the spec-writing interface | ||
* can be accessed in workers via jasmine-core's `noGlobals` method, e.g.: | ||
* | ||
* `const {describe, it, expect, jasmine} = require('jasmine-core').noGlobals();` | ||
* | ||
* @name ParallelRunnerOptions#globals | ||
* @type (boolean | undefined) | ||
* @default true | ||
*/ | ||
@@ -177,3 +188,3 @@ /** | ||
}); | ||
if (this.exitOnCompletion) { | ||
@@ -207,2 +218,3 @@ if (this.hasUnhandledErrors_) { | ||
filter: filterString, | ||
globals: this.globals_, | ||
env: this.envConfig_, | ||
@@ -271,3 +283,2 @@ }; | ||
await Promise.all(workerPromises); | ||
await new Promise(resolve => this.cluster_.disconnect(resolve)); | ||
} | ||
@@ -317,2 +328,12 @@ | ||
case 'uncaughtException': | ||
this.addTopLevelError_('lateError', | ||
'Uncaught exception in worker process', msg.error); | ||
break; | ||
case 'unhandledRejection': | ||
this.addTopLevelError_('lateError', | ||
'Unhandled promise rejection in worker process', msg.error); | ||
break; | ||
case 'reporterEvent': | ||
@@ -417,2 +438,15 @@ this.handleReporterEvent_(msg.eventName, msg.payload); | ||
} | ||
addTopLevelError_(type, msgPrefix, serializedError) { | ||
// Match how jasmine-core reports these in non-parallel situations | ||
this.executionState_.failedExpectations.push({ | ||
actual: '', | ||
expected: '', | ||
globalErrorType: 'lateError', | ||
matcherName: '', | ||
message: `${msgPrefix}: ${serializedError.message}`, | ||
passed: false, | ||
stack: serializedError.stack, | ||
}); | ||
} | ||
} | ||
@@ -419,0 +453,0 @@ |
@@ -22,2 +22,25 @@ const ConsoleSpecFilter = require("./filters/console_spec_filter"); | ||
}); | ||
// Install global error handlers now, before jasmine-core is booted. | ||
// That allows jasmine-core to override them with its own more specific | ||
// handling. These handlers will take care of errors that occur in between | ||
// spec files. | ||
for (const errorType of ['uncaughtException', 'unhandledRejection']) { | ||
options.process.on(errorType, error => { | ||
if (this.clusterWorker_.isConnected()) { | ||
this.clusterWorker_.send({ | ||
type: errorType, | ||
error: serializeError(error) | ||
}); | ||
} else { | ||
// Don't try to report errors after disconnect. If we do, it'll cause | ||
// another unhandled exception. The resulting error-and-reporting loop | ||
// can keep the runner from finishing. | ||
console.error(`${errorType} in Jasmine worker process after disconnect:`, error); | ||
console.error('This error cannot be reported properly because it ' + | ||
'happened after the worker process was disconnected.' | ||
); | ||
} | ||
}); | ||
} | ||
} | ||
@@ -29,5 +52,11 @@ | ||
.then(core => { | ||
// TODO also support globals: false | ||
const bootedCore = core.boot(core); | ||
const env = bootedCore.getEnv(); | ||
let env; | ||
if (options.globals === false) { | ||
env = core.noGlobals().jasmine.getEnv(); | ||
} else { | ||
const bootedCore = core.boot(core); | ||
env = bootedCore.getEnv(); | ||
} | ||
env.addReporter(forwardingReporter(this.clusterWorker_)); | ||
@@ -34,0 +63,0 @@ env.addReporter({ |
@@ -44,2 +44,3 @@ const path = require('path'); | ||
options.globalSetupOrTeardownRunner || new GlobalSetupOrTeardownRunner(); | ||
this.globals_ = options.globals; | ||
} | ||
@@ -46,0 +47,0 @@ |
@@ -13,3 +13,3 @@ { | ||
"license": "MIT", | ||
"version": "5.0.0-alpha.1", | ||
"version": "5.0.0-beta.0", | ||
"repository": { | ||
@@ -35,4 +35,4 @@ "type": "git", | ||
"dependencies": { | ||
"glob": "^9.3.1", | ||
"jasmine-core": "~5.0.0-alpha.1" | ||
"glob": "^10.2.2", | ||
"jasmine-core": "~5.0.0-beta.0" | ||
}, | ||
@@ -39,0 +39,0 @@ "bin": "./bin/jasmine.js", |
@@ -53,3 +53,3 @@ [![Build Status](https://circleci.com/gh/jasmine/jasmine-npm.svg?style=shield)](https://circleci.com/gh/jasmine/jasmine-npm) | ||
Jasmine supports Node 18 and 16.14-16.19. | ||
Jasmine supports Node 18 and 20. | ||
@@ -56,0 +56,0 @@ ## Support |
75607
2085
+ Added@isaacs/cliui@8.0.2(transitive)
+ Added@pkgjs/parseargs@0.11.0(transitive)
+ Addedansi-regex@5.0.16.0.1(transitive)
+ Addedansi-styles@4.3.06.2.1(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addedeastasianwidth@0.2.0(transitive)
+ Addedemoji-regex@8.0.09.2.2(transitive)
+ Addedforeground-child@3.1.1(transitive)
+ Addedglob@10.3.15(transitive)
+ Addedis-fullwidth-code-point@3.0.0(transitive)
+ Addedjackspeak@2.3.6(transitive)
+ Addedminimatch@9.0.4(transitive)
+ Addedstring-width@4.2.35.1.2(transitive)
+ Addedstrip-ansi@6.0.17.1.0(transitive)
+ Addedwrap-ansi@7.0.08.1.0(transitive)
- Removedfs.realpath@1.0.0(transitive)
- Removedglob@9.3.5(transitive)
- Removedminimatch@8.0.4(transitive)
- Removedminipass@4.2.8(transitive)
Updatedglob@^10.2.2
Updatedjasmine-core@~5.0.0-beta.0