Redesigned moudule system
* Top level private APIs (e.g. jasmine.private.whatever) are no longer exposed * jasmineRequire is no longer exposed * core is self-booting * Globals are automatically created in browsers. (They can subsequently be removed by user code if desired.) * Globals are *not* automatically created in Node. An installGlobals function is exported instead. The jasmine package calls installGlobals unless configured not to do so. * In Node, the same instance is returned each time jasmine-core is imported. A reset function is exported. It effectively resets all state by discarding the env and creating a new one. This allows mulitple sequential runs within the same process to be independent of each other, but does not allow multiple concurrent runs. (That probably never worked anyway.) Fixes #2094
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
getJasmineRequireObj().SuiteBuilder = function(j$) {
|
||||
getJasmineRequireObj().SuiteBuilder = function(j$, private$) {
|
||||
'use strict';
|
||||
|
||||
class SuiteBuilder {
|
||||
@@ -94,7 +94,7 @@ getJasmineRequireObj().SuiteBuilder = function(j$) {
|
||||
ensureIsFunctionOrAsync(fn, 'fit');
|
||||
|
||||
if (timeout) {
|
||||
j$.private.util.validateTimeout(timeout);
|
||||
private$.util.validateTimeout(timeout);
|
||||
}
|
||||
const spec = this.specFactory_(description, fn, timeout, filename);
|
||||
this.currentDeclarationSuite_.addChild(spec);
|
||||
@@ -107,7 +107,7 @@ getJasmineRequireObj().SuiteBuilder = function(j$) {
|
||||
ensureIsFunctionOrAsync(beforeEachFunction, 'beforeEach');
|
||||
|
||||
if (timeout) {
|
||||
j$.private.util.validateTimeout(timeout);
|
||||
private$.util.validateTimeout(timeout);
|
||||
}
|
||||
|
||||
this.currentDeclarationSuite_.beforeEach({
|
||||
@@ -120,7 +120,7 @@ getJasmineRequireObj().SuiteBuilder = function(j$) {
|
||||
ensureIsFunctionOrAsync(beforeAllFunction, 'beforeAll');
|
||||
|
||||
if (timeout) {
|
||||
j$.private.util.validateTimeout(timeout);
|
||||
private$.util.validateTimeout(timeout);
|
||||
}
|
||||
|
||||
this.currentDeclarationSuite_.beforeAll({
|
||||
@@ -133,7 +133,7 @@ getJasmineRequireObj().SuiteBuilder = function(j$) {
|
||||
ensureIsFunctionOrAsync(afterEachFunction, 'afterEach');
|
||||
|
||||
if (timeout) {
|
||||
j$.private.util.validateTimeout(timeout);
|
||||
private$.util.validateTimeout(timeout);
|
||||
}
|
||||
|
||||
afterEachFunction.isCleanup = true;
|
||||
@@ -147,7 +147,7 @@ getJasmineRequireObj().SuiteBuilder = function(j$) {
|
||||
ensureIsFunctionOrAsync(afterAllFunction, 'afterAll');
|
||||
|
||||
if (timeout) {
|
||||
j$.private.util.validateTimeout(timeout);
|
||||
private$.util.validateTimeout(timeout);
|
||||
}
|
||||
|
||||
this.currentDeclarationSuite_.afterAll({
|
||||
@@ -158,7 +158,7 @@ getJasmineRequireObj().SuiteBuilder = function(j$) {
|
||||
|
||||
it_(description, fn, timeout, filename) {
|
||||
if (timeout) {
|
||||
j$.private.util.validateTimeout(timeout);
|
||||
private$.util.validateTimeout(timeout);
|
||||
}
|
||||
|
||||
this.checkDuplicate_(description, 'spec');
|
||||
@@ -197,7 +197,7 @@ getJasmineRequireObj().SuiteBuilder = function(j$) {
|
||||
const parentSuite = this.currentDeclarationSuite_;
|
||||
const reportedParentSuiteId =
|
||||
parentSuite === this.topSuite ? null : parentSuite.id;
|
||||
return new j$.private.Suite({
|
||||
return new private$.Suite({
|
||||
id: 'suite' + this.nextSuiteId_++,
|
||||
description,
|
||||
filename,
|
||||
@@ -239,7 +239,7 @@ getJasmineRequireObj().SuiteBuilder = function(j$) {
|
||||
const config = this.env_.configuration();
|
||||
const suite = this.currentDeclarationSuite_;
|
||||
const parentSuiteId = suite === this.topSuite ? null : suite.id;
|
||||
const spec = new j$.private.Spec({
|
||||
const spec = new private$.Spec({
|
||||
id: 'spec' + this.nextSpecId_++,
|
||||
filename,
|
||||
parentSuiteId,
|
||||
@@ -302,21 +302,21 @@ getJasmineRequireObj().SuiteBuilder = function(j$) {
|
||||
}
|
||||
|
||||
function ensureIsFunction(fn, caller) {
|
||||
if (!j$.private.isFunction(fn)) {
|
||||
if (!private$.isFunction(fn)) {
|
||||
throw new Error(
|
||||
caller +
|
||||
' expects a function argument; received ' +
|
||||
j$.private.getType(fn)
|
||||
private$.getType(fn)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function ensureIsFunctionOrAsync(fn, caller) {
|
||||
if (!j$.private.isFunction(fn) && !j$.private.isAsyncFunction(fn)) {
|
||||
if (!private$.isFunction(fn) && !private$.isAsyncFunction(fn)) {
|
||||
throw new Error(
|
||||
caller +
|
||||
' expects a function argument; received ' +
|
||||
j$.private.getType(fn)
|
||||
private$.getType(fn)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user