Merge branch 'main' into 3.99

This commit is contained in:
Steve Gravrock
2020-09-14 18:39:32 -07:00
82 changed files with 2725 additions and 1286 deletions
@@ -19,8 +19,8 @@ describe('Asymmetric equality testers (Integration)', function () {
.toBeUndefined();
};
env.addReporter({specDone: specExpectations, jasmineDone: done});
env.execute();
env.addReporter({specDone: specExpectations});
env.execute(null, done);
});
}
@@ -43,8 +43,8 @@ describe('Asymmetric equality testers (Integration)', function () {
.not.toEqual('');
};
env.addReporter({specDone: specExpectations, jasmineDone: done});
env.execute();
env.addReporter({specDone: specExpectations});
env.execute(null, done);
});
}
@@ -1,3 +1,4 @@
/* eslint-disable compat/compat */
describe('Custom Async Matchers (Integration)', function() {
var env;
@@ -27,8 +28,8 @@ describe('Custom Async Matchers (Integration)', function() {
expect(result.status).toEqual('passed');
};
env.addReporter({ specDone: specExpectations, jasmineDone: done });
env.execute();
env.addReporter({ specDone: specExpectations });
env.execute(null, done);
});
it('uses the negative compare function for a negative comparison, if provided', function(done) {
@@ -51,8 +52,8 @@ describe('Custom Async Matchers (Integration)', function() {
expect(result.status).toEqual('passed');
};
env.addReporter({ specDone: specExpectations, jasmineDone: done });
env.execute();
env.addReporter({ specDone: specExpectations });
env.execute(null, done);
});
it('generates messages with the same rules as built in matchers absent a custom message', function(done) {
@@ -76,8 +77,8 @@ describe('Custom Async Matchers (Integration)', function() {
expect(result.failedExpectations[0].message).toEqual("Expected 'a' to be real.");
};
env.addReporter({ specDone: specExpectations, jasmineDone: done });
env.execute();
env.addReporter({ specDone: specExpectations });
env.execute(null, done);
});
it("passes the jasmine utility to the matcher factory", function (done) {
@@ -106,8 +107,8 @@ describe('Custom Async Matchers (Integration)', function() {
);
};
env.addReporter({specDone: specExpectations, jasmineDone: done});
env.execute();
env.addReporter({ specDone: specExpectations });
env.execute(null, done);
});
// TODO: remove this in the next major release.
@@ -177,8 +178,8 @@ describe('Custom Async Matchers (Integration)', function() {
expect(result.failedExpectations).toEqual([]);
};
env.addReporter({ specDone: specExpectations, jasmineDone: done });
env.execute();
env.addReporter({ specDone: specExpectations });
env.execute(null, done);
});
it('logs a deprecation once per matcher if the matcher factory takes two arguments', function (done) {
+20 -20
View File
@@ -37,9 +37,9 @@ describe("Custom Matchers (Integration)", function () {
expect(firstSpecResult.failedExpectations[0].message).toEqual("matcherForSpec: actual: zzz; expected: yyy");
done();
};
env.addReporter({ specDone:specDoneSpy, jasmineDone: expectations});
env.addReporter({ specDone:specDoneSpy });
env.execute();
env.execute(null, expectations);
});
it("passes the spec if the custom matcher passes", function(done) {
@@ -57,8 +57,8 @@ describe("Custom Matchers (Integration)", function () {
expect(result.status).toEqual('passed');
};
env.addReporter({ specDone: specExpectations, jasmineDone: done });
env.execute();
env.addReporter({ specDone: specExpectations });
env.execute(null, done);
});
it("passes the spec if the custom equality matcher passes for types nested inside asymmetric equality testers", function(done) {
@@ -81,8 +81,8 @@ describe("Custom Matchers (Integration)", function () {
expect(result.status).toEqual('passed');
};
env.addReporter({ specDone: specExpectations, jasmineDone: done });
env.execute();
env.addReporter({ specDone: specExpectations });
env.execute(null, done);
});
it("supports asymmetric equality testers that take a list of custom equality testers", function(done) {
@@ -112,8 +112,8 @@ describe("Custom Matchers (Integration)", function () {
expect(result.status).toEqual('passed');
};
env.addReporter({ specDone: specExpectations, jasmineDone: done });
env.execute();
env.addReporter({ specDone: specExpectations });
env.execute(null, done);
});
it("displays an appropriate failure message if a custom equality matcher fails", function(done) {
@@ -139,8 +139,8 @@ describe("Custom Matchers (Integration)", function () {
);
};
env.addReporter({ specDone: specExpectations, jasmineDone: done });
env.execute();
env.addReporter({ specDone: specExpectations });
env.execute(null, done);
});
it("uses the negative compare function for a negative comparison, if provided", function(done) {
@@ -161,8 +161,8 @@ describe("Custom Matchers (Integration)", function () {
expect(result.status).toEqual('passed');
};
env.addReporter({ specDone: specExpectations, jasmineDone: done });
env.execute();
env.addReporter({ specDone: specExpectations });
env.execute(null, done);
});
it("generates messages with the same rules as built in matchers absent a custom message", function(done) {
@@ -184,8 +184,8 @@ describe("Custom Matchers (Integration)", function () {
expect(result.failedExpectations[0].message).toEqual("Expected 'a' to be real.");
};
env.addReporter({ specDone: specExpectations, jasmineDone: done });
env.execute();
env.addReporter({ specDone: specExpectations });
env.execute(null, done);
});
it("passes the expected and actual arguments to the comparison function", function(done) {
@@ -209,8 +209,8 @@ describe("Custom Matchers (Integration)", function () {
expect(argumentSpy).toHaveBeenCalledWith(true, "arg1", "arg2");
};
env.addReporter({ specDone: specExpectations, jasmineDone: done });
env.execute();
env.addReporter({ specDone: specExpectations });
env.execute(null, done);
});
it("passes the jasmine utility to the matcher factory", function (done) {
@@ -237,8 +237,8 @@ describe("Custom Matchers (Integration)", function () {
);
};
env.addReporter({specDone: specExpectations, jasmineDone: done});
env.execute();
env.addReporter({ specDone: specExpectations });
env.execute(null, done);
});
// TODO: remove this in the next major release.
@@ -306,8 +306,8 @@ describe("Custom Matchers (Integration)", function () {
expect(result.failedExpectations).toEqual([]);
};
env.addReporter({specDone: specExpectations, jasmineDone: done});
env.execute();
env.addReporter({specDone: specExpectations});
env.execute(null, done);
});
it('logs a deprecation once per matcher if the matcher factory takes two arguments', function(done) {
@@ -25,9 +25,9 @@ describe("Custom object formatters", function() {
expect(specResults[1].failedExpectations[0].message).toEqual("Expected 42 to be undefined.");
done();
};
env.addReporter({ specDone:specDone, jasmineDone: expectations});
env.addReporter({ specDone:specDone });
env.execute();
env.execute(null, expectations);
});
it("scopes custom object formatters to a suite", function(done) {
@@ -54,9 +54,9 @@ describe("Custom object formatters", function() {
expect(specResults[1].failedExpectations[0].message).toEqual("Expected custom(42) to be undefined.");
done();
};
env.addReporter({ specDone:specDone, jasmineDone: expectations});
env.addReporter({ specDone:specDone });
env.execute();
env.execute(null, expectations);
});
it("throws an exception if you try to add a custom object formatter outside a runable", function() {
@@ -15,6 +15,7 @@ describe('Custom Spy Strategies (Integration)', function() {
.and.returnValue(42);
var strategy = jasmine.createSpy('custom strategy')
.and.returnValue(plan);
var jasmineDone = jasmine.createSpy('jasmineDone');
env.describe('suite defining a custom spy strategy', function() {
env.beforeEach(function() {
@@ -33,13 +34,14 @@ describe('Custom Spy Strategies (Integration)', function() {
expect(env.createSpy('something').and.frobnicate).toBeUndefined();
});
function jasmineDone(result) {
function expectations() {
var result = jasmineDone.calls.argsFor(0)[0];
expect(result.overallStatus).toEqual('passed');
done();
}
env.addReporter({ jasmineDone: jasmineDone });
env.execute();
env.execute(null, expectations);
});
it('allows adding more strategies local to a spec', function(done) {
@@ -47,6 +49,7 @@ describe('Custom Spy Strategies (Integration)', function() {
.and.returnValue(42);
var strategy = jasmine.createSpy('custom strategy')
.and.returnValue(plan);
var jasmineDone = jasmine.createSpy('jasmineDone');
env.it('spec defining a custom spy strategy', function() {
env.addSpyStrategy('frobnicate', strategy);
@@ -60,13 +63,14 @@ describe('Custom Spy Strategies (Integration)', function() {
expect(env.createSpy('something').and.frobnicate).toBeUndefined();
});
function jasmineDone(result) {
function expectations() {
var result = jasmineDone.calls.argsFor(0)[0];
expect(result.overallStatus).toEqual('passed');
done();
}
env.addReporter({ jasmineDone: jasmineDone });
env.execute();
env.execute(null, expectations);
});
it('allows using custom strategies on a per-argument basis', function(done) {
@@ -74,6 +78,7 @@ describe('Custom Spy Strategies (Integration)', function() {
.and.returnValue(42);
var strategy = jasmine.createSpy('custom strategy')
.and.returnValue(plan);
var jasmineDone = jasmine.createSpy('jasmineDone');
env.it('spec defining a custom spy strategy', function() {
env.addSpyStrategy('frobnicate', strategy);
@@ -91,13 +96,14 @@ describe('Custom Spy Strategies (Integration)', function() {
expect(env.createSpy('something').and.frobnicate).toBeUndefined();
});
function jasmineDone(result) {
function expectations() {
var result = jasmineDone.calls.argsFor(0)[0];
expect(result.overallStatus).toEqual('passed');
done();
}
env.addReporter({ jasmineDone: jasmineDone });
env.execute();
env.execute(null, expectations);
});
it('allows multiple custom strategies to be used', function(done) {
@@ -105,7 +111,9 @@ describe('Custom Spy Strategies (Integration)', function() {
strategy1 = jasmine.createSpy('strat 1').and.returnValue(plan1),
plan2 = jasmine.createSpy('plan 2').and.returnValue(24),
strategy2 = jasmine.createSpy('strat 2').and.returnValue(plan2),
specDone = jasmine.createSpy('specDone');
specDone = jasmine.createSpy('specDone'),
jasmineDone = jasmine.createSpy('jasmineDone');
env.beforeEach(function() {
env.addSpyStrategy('frobnicate', strategy1);
@@ -130,13 +138,14 @@ describe('Custom Spy Strategies (Integration)', function() {
expect(plan2).toHaveBeenCalled();
});
function jasmineDone(result) {
function expectations() {
var result = jasmineDone.calls.argsFor(0)[0];
expect(result.overallStatus).toEqual('passed');
expect(specDone.calls.count()).toBe(2);
done();
}
env.addReporter({ jasmineDone: jasmineDone, specDone: specDone });
env.execute();
env.execute(null, expectations);
});
});
@@ -29,13 +29,15 @@ describe('Default Spy Strategy (Integration)', function() {
expect(spy()).toBeUndefined();
});
function jasmineDone(result) {
function expectations() {
var result = jasmineDone.calls.argsFor(0)[0];
expect(result.overallStatus).toEqual('passed');
done();
}
var jasmineDone = jasmine.createSpy('jasmineDone');
env.addReporter({ jasmineDone: jasmineDone });
env.execute();
env.execute(null, expectations);
});
it('uses the default spy strategy defined when the spy is created', function (done) {
@@ -61,12 +63,14 @@ describe('Default Spy Strategy (Integration)', function() {
expect(d.and.isConfigured()).toBe(false);
});
function jasmineDone(result) {
function expectations() {
var result = jasmineDone.calls.argsFor(0)[0];
expect(result.overallStatus).toEqual('passed');
done();
}
var jasmineDone = jasmine.createSpy('jasmineDone');
env.addReporter({ jasmineDone: jasmineDone });
env.execute();
env.execute(null, expectations);
});
});
File diff suppressed because it is too large Load Diff
+56 -27
View File
@@ -28,8 +28,8 @@ describe('Matchers (Integration)', function() {
.toBeUndefined();
};
env.addReporter({ specDone: specExpectations, jasmineDone: done });
env.execute();
env.addReporter({ specDone: specExpectations });
env.execute(null, done);
});
}
@@ -47,12 +47,15 @@ describe('Matchers (Integration)', function() {
expect(result.failedExpectations[0].message)
.withContext('Failed with a thrown error rather than a matcher failure')
.not.toMatch(/^Error: /);
expect(result.failedExpectations[0].message)
.withContext('Failed with a thrown type error rather than a matcher failure')
.not.toMatch(/^TypeError: /);
expect(result.failedExpectations[0].matcherName).withContext('Matcher name')
.not.toEqual('');
};
env.addReporter({ specDone: specExpectations, jasmineDone: done });
env.execute();
env.addReporter({ specDone: specExpectations });
env.execute(null, done);
});
}
@@ -72,8 +75,8 @@ describe('Matchers (Integration)', function() {
.toEqual(config.expectedMessage);
};
env.addReporter({specDone: specExpectations, jasmineDone: done});
env.execute();
env.addReporter({ specDone: specExpectations });
env.execute(null, done);
});
}
@@ -98,8 +101,8 @@ describe('Matchers (Integration)', function() {
.toBeUndefined();
};
env.addReporter({ specDone: specExpectations, jasmineDone: done });
env.execute();
env.addReporter({ specDone: specExpectations });
env.execute(null, done);
});
}
@@ -123,8 +126,8 @@ describe('Matchers (Integration)', function() {
.not.toEqual('');
};
env.addReporter({ specDone: specExpectations, jasmineDone: done });
env.execute();
env.addReporter({ specDone: specExpectations });
env.execute(null, done);
});
}
@@ -146,8 +149,8 @@ describe('Matchers (Integration)', function() {
.toEqual(config.expectedMessage);
};
env.addReporter({specDone: specExpectations, jasmineDone: done});
env.execute();
env.addReporter({ specDone: specExpectations });
env.execute(null, done);
});
}
@@ -332,11 +335,11 @@ describe('Matchers (Integration)', function() {
describe('toBeResolved', function() {
verifyPassesAsync(function(env) {
return env.expectAsync(Promise.resolve()).toBeResolved();
return env.expectAsync(Promise.resolve()).toBeResolved(); // eslint-disable-line compat/compat
});
verifyFailsAsync(function(env) {
return env.expectAsync(Promise.reject()).toBeResolved();
return env.expectAsync(Promise.reject()).toBeResolved(); // eslint-disable-line compat/compat
});
});
@@ -345,11 +348,11 @@ describe('Matchers (Integration)', function() {
env.addCustomEqualityTester(function(a, b) {
return a.toString() === b.toString();
});
return env.expectAsync(Promise.resolve('5')).toBeResolvedTo(5);
return env.expectAsync(Promise.resolve('5')).toBeResolvedTo(5); // eslint-disable-line compat/compat
});
verifyFailsAsync(function(env) {
return env.expectAsync(Promise.resolve('foo')).toBeResolvedTo('bar');
return env.expectAsync(Promise.resolve('foo')).toBeResolvedTo('bar'); // eslint-disable-line compat/compat
});
verifyFailsWithCustomObjectFormattersAsync({
@@ -357,7 +360,7 @@ describe('Matchers (Integration)', function() {
return '|' + val + '|';
},
expectations: function(env) {
return env.expectAsync(Promise.resolve('x')).toBeResolvedTo('y');
return env.expectAsync(Promise.resolve('x')).toBeResolvedTo('y'); // eslint-disable-line compat/compat
},
expectedMessage: 'Expected a promise to be resolved to |y| ' +
'but it was resolved to |x|.'
@@ -366,11 +369,11 @@ describe('Matchers (Integration)', function() {
describe('toBeRejected', function() {
verifyPassesAsync(function(env) {
return env.expectAsync(Promise.reject('nope')).toBeRejected();
return env.expectAsync(Promise.reject('nope')).toBeRejected(); // eslint-disable-line compat/compat
});
verifyFailsAsync(function(env) {
return env.expectAsync(Promise.resolve()).toBeRejected();
return env.expectAsync(Promise.resolve()).toBeRejected(); // eslint-disable-line compat/compat
});
});
@@ -379,11 +382,11 @@ describe('Matchers (Integration)', function() {
env.addCustomEqualityTester(function(a, b) {
return a.toString() === b.toString();
});
return env.expectAsync(Promise.reject('5')).toBeRejectedWith(5);
return env.expectAsync(Promise.reject('5')).toBeRejectedWith(5); // eslint-disable-line compat/compat
});
verifyFailsAsync(function(env) {
return env.expectAsync(Promise.resolve()).toBeRejectedWith('nope');
return env.expectAsync(Promise.resolve()).toBeRejectedWith('nope'); // eslint-disable-line compat/compat
});
verifyFailsWithCustomObjectFormattersAsync({
@@ -391,7 +394,7 @@ describe('Matchers (Integration)', function() {
return '|' + val + '|';
},
expectations: function(env) {
return env.expectAsync(Promise.reject('x')).toBeRejectedWith('y');
return env.expectAsync(Promise.reject('x')).toBeRejectedWith('y'); // eslint-disable-line compat/compat
},
expectedMessage: 'Expected a promise to be rejected with |y| ' +
'but it was rejected with |x|.'
@@ -400,11 +403,11 @@ describe('Matchers (Integration)', function() {
describe('toBeRejectedWithError', function() {
verifyPassesAsync(function(env) {
return env.expectAsync(Promise.reject(new Error())).toBeRejectedWithError(Error);
return env.expectAsync(Promise.reject(new Error())).toBeRejectedWithError(Error); // eslint-disable-line compat/compat
});
verifyFailsAsync(function(env) {
return env.expectAsync(Promise.resolve()).toBeRejectedWithError(Error);
return env.expectAsync(Promise.resolve()).toBeRejectedWithError(Error); // eslint-disable-line compat/compat
});
verifyFailsWithCustomObjectFormattersAsync({
@@ -412,7 +415,7 @@ describe('Matchers (Integration)', function() {
return '|' + val + '|';
},
expectations: function(env) {
return env.expectAsync(Promise.reject('foo')).toBeRejectedWithError('foo');
return env.expectAsync(Promise.reject('foo')).toBeRejectedWithError('foo'); // eslint-disable-line compat/compat
},
expectedMessage: 'Expected a promise to be rejected with Error: |foo| ' +
'but it was rejected with |foo|.'
@@ -477,9 +480,9 @@ describe('Matchers (Integration)', function() {
verifyFailsWithCustomObjectFormatters({
formatter: function(val) {
if (val === 5) {
return "five"
return 'five';
} else if (val === 4) {
return "four"
return 'four';
}
},
expectations: function(env) {
@@ -489,6 +492,16 @@ describe('Matchers (Integration)', function() {
});
});
describe('toHaveSize', function() {
verifyPasses(function(env) {
env.expect(['a','b']).toHaveSize(2);
});
verifyFails(function(env) {
env.expect(['a','b']).toHaveSize(1);
});
});
describe('toHaveBeenCalled', function() {
verifyPasses(function(env) {
var spy = env.createSpy('spy');
@@ -560,6 +573,22 @@ describe('Matchers (Integration)', function() {
});
});
describe('toHaveBeenCalledOnceWith', function() {
verifyPasses(function(env) {
var spy = env.createSpy();
spy('5', 3);
env.addCustomEqualityTester(function(a, b) {
return a.toString() === b.toString();
});
env.expect(spy).toHaveBeenCalledOnceWith(5, 3);
});
verifyFails(function(env) {
var spy = env.createSpy();
env.expect(spy).toHaveBeenCalledOnceWith(5, 3);
});
});
describe('toHaveClass', function() {
beforeEach(function() {
this.domHelpers = jasmine.getEnv().domHelpers();
+59 -159
View File
@@ -66,17 +66,14 @@ describe("spec running", function () {
expect(bar).toEqual(0);
expect(baz).toEqual(0);
expect(quux).toEqual(0);
var assertions = function() {
env.execute(null, function() {
expect(foo).toEqual(1);
expect(bar).toEqual(1);
expect(baz).toEqual(1);
expect(quux).toEqual(1);
done();
};
env.addReporter({ jasmineDone: assertions });
env.execute();
});
});
it("should permit nested describes", function(done) {
@@ -136,7 +133,7 @@ describe("spec running", function () {
});
});
var assertions = function() {
env.execute(null, function() {
var expected = [
"topSuite beforeEach",
"outer beforeEach",
@@ -168,11 +165,7 @@ describe("spec running", function () {
];
expect(actions).toEqual(expected);
done();
};
env.addReporter({jasmineDone: assertions});
env.execute();
});
});
it("should run multiple befores and afters ordered so functions declared later are treated as more specific", function(done) {
@@ -232,7 +225,7 @@ describe("spec running", function () {
});
});
var assertions = function() {
env.execute(null, function() {
var expected = [
"runner beforeAll1",
"runner beforeAll2",
@@ -250,11 +243,7 @@ describe("spec running", function () {
];
expect(actions).toEqual(expected);
done();
};
env.addReporter({jasmineDone: assertions});
env.execute();
});
});
it('should run beforeAlls before beforeEachs and afterAlls after afterEachs', function(done) {
@@ -298,7 +287,7 @@ describe("spec running", function () {
});
});
var assertions = function() {
env.execute(null, function() {
var expected = [
"runner beforeAll",
"inner beforeAll",
@@ -312,10 +301,7 @@ describe("spec running", function () {
];
expect(actions).toEqual(expected);
done();
};
env.addReporter({jasmineDone: assertions});
env.execute();
});
});
it('should run beforeAlls and afterAlls in the order declared when runnablesToRun is provided', function(done) {
@@ -365,7 +351,7 @@ describe("spec running", function () {
});
});
var assertions = function() {
env.execute([spec2.id, spec.id], function() {
var expected = [
"runner beforeAll",
"inner beforeAll",
@@ -385,10 +371,7 @@ describe("spec running", function () {
];
expect(actions).toEqual(expected);
done();
};
env.addReporter({jasmineDone: assertions});
env.execute([spec2.id, spec.id]);
});
});
it('only runs *Alls once in a focused suite', function(done){
@@ -406,13 +389,10 @@ describe("spec running", function () {
});
});
var assertions = function() {
env.execute(null, function() {
expect(actions).toEqual(['beforeAll', 'spec', 'afterAll']);
done();
};
env.addReporter({jasmineDone: assertions});
env.execute();
});
});
describe('focused runnables', function() {
@@ -435,7 +415,7 @@ describe("spec running", function () {
});
});
var assertions = function() {
env.execute(null, function() {
var expected = [
'beforeAll',
'beforeEach',
@@ -449,10 +429,7 @@ describe("spec running", function () {
];
expect(actions).toEqual(expected);
done();
};
env.addReporter({jasmineDone: assertions});
env.execute();
});
});
it('focused specs in focused suites cause non-focused siblings to not run', function(done){
@@ -467,14 +444,11 @@ describe("spec running", function () {
});
});
var assertions = function() {
env.execute(null, function() {
var expected = ['focused spec'];
expect(actions).toEqual(expected);
done();
};
env.addReporter({jasmineDone: assertions});
env.execute();
});
});
it('focused suites in focused suites cause non-focused siblings to not run', function(done){
@@ -491,14 +465,11 @@ describe("spec running", function () {
});
});
var assertions = function() {
env.execute(null, function() {
var expected = ['inner spec'];
expect(actions).toEqual(expected);
done();
};
env.addReporter({jasmineDone: assertions});
env.execute();
});
});
it('focused runnables unfocus ancestor focused suites', function(done) {
@@ -515,14 +486,11 @@ describe("spec running", function () {
});
});
var assertions = function() {
env.execute(null, function() {
var expected = ['focused spec'];
expect(actions).toEqual(expected);
done();
};
env.addReporter({jasmineDone: assertions});
env.execute();
});
});
});
@@ -534,14 +502,10 @@ describe("spec running", function () {
});
});
var assertions = function() {
env.execute(null, function() {
expect(specInADisabledSuite).not.toHaveBeenCalled();
done();
};
env.addReporter({jasmineDone: assertions});
env.execute();
});
});
it("shouldn't run before/after functions in disabled suites", function(done) {
@@ -556,14 +520,10 @@ describe("spec running", function () {
env.it('spec inside a disabled suite', shouldNotRun);
});
var assertions = function() {
env.execute(null, function() {
expect(shouldNotRun).not.toHaveBeenCalled();
done();
};
env.addReporter({jasmineDone: assertions});
env.execute();
});
});
it("should allow top level suites to be disabled", function(done) {
@@ -577,15 +537,11 @@ describe("spec running", function () {
env.it('another spec', otherSpec);
});
var assertions = function() {
env.execute(null, function() {
expect(specInADisabledSuite).not.toHaveBeenCalled();
expect(otherSpec).toHaveBeenCalled();
done();
};
env.addReporter({jasmineDone: assertions});
env.execute();
});
});
it("should set all pending specs to pending when a suite is run", function(done) {
@@ -594,31 +550,20 @@ describe("spec running", function () {
pendingSpec = env.it("I am a pending spec");
});
var assertions = function() {
env.execute(null, function() {
expect(pendingSpec.status()).toBe("pending");
done();
};
env.addReporter({jasmineDone: assertions});
env.execute();
});
});
it("should recover gracefully when there are errors in describe functions", function(done) {
var specs = [],
reporter = jasmine.createSpyObj(['specDone', 'suiteDone', 'jasmineDone']);
reporter = jasmine.createSpyObj(['specDone', 'suiteDone']);
reporter.specDone.and.callFake(function(result) {
specs.push(result.fullName);
});
reporter.jasmineDone.and.callFake(function() {
expect(specs).toEqual(['outer1 inner1 should thingy', 'outer1 inner2 should other thingy', 'outer2 should xxx']);
expect(reporter.suiteDone).toHaveFailedExpectationsForRunnable('outer1 inner1', [/inner error/]);
expect(reporter.suiteDone).toHaveFailedExpectationsForRunnable('outer1', [/outer error/]);
done();
});
expect(function() {
env.describe("outer1", function() {
env.describe("inner1", function() {
@@ -647,7 +592,12 @@ describe("spec running", function () {
});
env.addReporter(reporter);
env.execute();
env.execute(null, function() {
expect(specs).toEqual(['outer1 inner1 should thingy', 'outer1 inner2 should other thingy', 'outer2 should xxx']);
expect(reporter.suiteDone).toHaveFailedExpectationsForRunnable('outer1 inner1', [/inner error/]);
expect(reporter.suiteDone).toHaveFailedExpectationsForRunnable('outer1', [/outer error/]);
done();
});
});
it("re-enters suites that have no *Alls", function(done) {
@@ -668,14 +618,10 @@ describe("spec running", function () {
actions.push("spec3");
});
env.addReporter({
jasmineDone: function() {
expect(actions).toEqual(["spec2", "spec3", "spec1"]);
done();
}
env.execute([spec2.id, spec3.id, spec1.id], function() {
expect(actions).toEqual(["spec2", "spec3", "spec1"]);
done();
});
env.execute([spec2.id, spec3.id, spec1.id]);
});
it("refuses to re-enter suites with a beforeAll", function() {
@@ -698,16 +644,10 @@ describe("spec running", function () {
actions.push("spec3");
});
env.addReporter({
jasmineDone: function() {
expect(actions).toEqual([]);
done();
}
});
expect(function() {
env.execute([spec2.id, spec3.id, spec1.id]);
}).toThrowError(/beforeAll/);
expect(actions).toEqual([]);
});
it("refuses to re-enter suites with a afterAll", function() {
@@ -730,16 +670,10 @@ describe("spec running", function () {
actions.push("spec3");
});
env.addReporter({
jasmineDone: function() {
expect(actions).toEqual([]);
done();
}
});
expect(function() {
env.execute([spec2.id, spec3.id, spec1.id]);
}).toThrowError(/afterAll/);
expect(actions).toEqual([]);
});
it("should run the tests in a consistent order when a seed is supplied", function(done) {
@@ -800,7 +734,7 @@ describe("spec running", function () {
});
});
var assertions = function() {
env.execute(null, function() {
var expected = [
'topSuite beforeEach',
'outer beforeEach',
@@ -832,11 +766,7 @@ describe("spec running", function () {
];
expect(actions).toEqual(expected);
done();
};
env.addReporter({jasmineDone: assertions});
env.execute();
});
});
describe("When throwOnExpectationFailure is set", function() {
@@ -870,18 +800,14 @@ describe("spec running", function () {
env.configure({oneFailurePerSpec: true});
var assertions = function() {
env.execute(null, function() {
expect(actions).toEqual([
'outer beforeEach',
'inner afterEach',
'outer afterEach'
]);
done();
};
env.addReporter({jasmineDone: assertions});
env.execute();
});
});
it("skips to cleanup functions after done.fail is called", function(done) {
@@ -905,17 +831,13 @@ describe("spec running", function () {
env.configure({oneFailurePerSpec: true});
var assertions = function() {
env.execute(null, function() {
expect(actions).toEqual([
'beforeEach',
'afterEach'
]);
done();
};
env.addReporter({jasmineDone: assertions});
env.execute();
});
});
it("skips to cleanup functions when an async function times out", function(done) {
@@ -937,17 +859,13 @@ describe("spec running", function () {
env.configure({oneFailurePerSpec: true});
var assertions = function() {
env.execute(null, function() {
expect(actions).toEqual([
'beforeEach',
'afterEach'
]);
done();
};
env.addReporter({jasmineDone: assertions});
env.execute();
});
});
it("skips to cleanup functions after an error with deprecations", function(done) {
@@ -982,7 +900,7 @@ describe("spec running", function () {
env.throwOnExpectationFailure(true);
var assertions = function() {
env.execute(null, function() {
expect(actions).toEqual([
'outer beforeEach',
'inner afterEach',
@@ -990,11 +908,7 @@ describe("spec running", function () {
]);
expect(env.deprecated).toHaveBeenCalled();
done();
};
env.addReporter({jasmineDone: assertions});
env.execute();
});
});
it("skips to cleanup functions after done.fail is called with deprecations", function(done) {
@@ -1020,18 +934,14 @@ describe("spec running", function () {
env.throwOnExpectationFailure(true);
var assertions = function() {
env.execute(null, function() {
expect(actions).toEqual([
'beforeEach',
'afterEach'
]);
expect(env.deprecated).toHaveBeenCalled();
done();
};
env.addReporter({jasmineDone: assertions});
env.execute();
});
});
it("skips to cleanup functions when an async function times out with deprecations", function(done) {
@@ -1055,18 +965,14 @@ describe("spec running", function () {
env.throwOnExpectationFailure(true);
var assertions = function() {
env.execute(null, function() {
expect(actions).toEqual([
'beforeEach',
'afterEach'
]);
expect(env.deprecated).toHaveBeenCalled();
done();
};
env.addReporter({jasmineDone: assertions});
env.execute();
});
});
});
@@ -1089,13 +995,10 @@ describe("spec running", function () {
env.configure({random: false, failFast: true});
var assertions = function() {
env.execute(null, function() {
expect(actions).toEqual(['fails']);
done();
};
env.addReporter({ jasmineDone: assertions });
env.execute();
});
});
it("does not run further specs when one fails when configured with deprecated option", function(done) {
@@ -1119,14 +1022,11 @@ describe("spec running", function () {
env.configure({random: false});
env.stopOnSpecFailure(true);
var assertions = function() {
env.execute(null, function() {
expect(actions).toEqual(['fails']);
expect(env.deprecated).toHaveBeenCalled();
done();
};
env.addReporter({ jasmineDone: assertions });
env.execute();
});
});
});
});