Introduce a configuration object to Env deprecating old single use functions

[finishes #159158038]
This commit is contained in:
Gregg Van Hove
2018-09-24 12:46:47 -07:00
parent 6b9ae2db7e
commit 92d0882a32
12 changed files with 544 additions and 156 deletions

View File

@@ -4,7 +4,7 @@ describe("Custom Matchers (Integration)", function() {
beforeEach(function() {
env = new jasmineUnderTest.Env();
env.randomizeTests(false);
env.configure({random: false});
});
it("allows adding more matchers local to a spec", function(done) {

View File

@@ -3,7 +3,7 @@ describe('Custom Spy Strategies (Integration)', function() {
beforeEach(function() {
env = new jasmineUnderTest.Env();
env.randomizeTests(false);
env.configure({random: false});
});
it('allows adding more strategies local to a suite', function(done) {

View File

@@ -17,7 +17,7 @@ describe("Env integration", function() {
};
env.addReporter({ jasmineDone: assertions});
env.randomizeTests(false);
env.configure({random: false});
env.describe("A Suite", function() {
env.it("with a spec", function() {
@@ -46,7 +46,7 @@ describe("Env integration", function() {
};
env.addReporter({ jasmineDone: assertions });
env.randomizeTests(false);
env.configure({random: false});
env.describe("Outer suite", function() {
env.it("an outer spec", function() {
@@ -81,7 +81,7 @@ describe("Env integration", function() {
};
env.addReporter({ jasmineDone: assertions });
env.randomizeTests(false);
env.configure({random: false});
env.describe("Outer suite", function() {
@@ -200,7 +200,7 @@ describe("Env integration", function() {
var env = new jasmineUnderTest.Env();
env.addReporter({jasmineDone: done});
env.randomizeTests(false);
env.configure({random: false});
env.describe("tests", function() {
var firstTimeThrough = true, firstSpecContext, secondSpecContext;
@@ -783,9 +783,11 @@ describe("Env integration", function() {
});
});
env.specFilter = function(spec) {
return /^first suite/.test(spec.getFullName());
};
env.configure({
specFilter: function(spec) {
return /^first suite/.test(spec.getFullName());
}
});
env.execute();
});
@@ -953,7 +955,7 @@ describe("Env integration", function() {
};
env.addReporter({ jasmineDone: assertions });
env.randomizeTests(false);
env.configure({random: false});
env.describe("tests", function() {
env.it("test with mock clock", function() {
@@ -1476,8 +1478,7 @@ describe("Env integration", function() {
"specStarted",
"specDone"
]);
env.randomizeTests(true);
env.seed('123456');
env.configure({random: true, seed: '123456'});
reporter.jasmineDone.and.callFake(function(doneArg) {
expect(reporter.jasmineStarted).toHaveBeenCalled();
@@ -1491,7 +1492,7 @@ describe("Env integration", function() {
});
env.addReporter(reporter);
env.randomizeTests(true);
env.configure({random: true});
env.execute();
});
@@ -1662,7 +1663,7 @@ describe("Env integration", function() {
});
env.addReporter(reporter);
env.randomizeTests(false);
env.configure({random: false});
env.describe("testing custom equality testers", function() {
env.it("with a custom tester", function() {
@@ -1698,7 +1699,7 @@ describe("Env integration", function() {
});
env.addReporter(reporter);
env.randomizeTests(false);
env.configure({random: false});
env.describe("testing custom equality testers", function() {
env.beforeAll(function() { env.addCustomEqualityTester(function(a, b) { return true; }); });
@@ -1739,7 +1740,7 @@ describe("Env integration", function() {
});
env.addReporter(reporter);
env.randomizeTests(false);
env.configure({random: false});
env.describe("testing custom equality testers", function() {
env.it("with a custom tester", function() {
@@ -1792,7 +1793,7 @@ describe("Env integration", function() {
});
env.addReporter(reporter);
env.randomizeTests(false);
env.configure({random: false});
env.describe("testing custom equality testers", function() {
env.beforeAll(function() { env.addCustomEqualityTester(function(a, b) { return true; })});

View File

@@ -4,7 +4,7 @@ describe("spec running", function () {
beforeEach(function() {
jasmine.getEnv().registerIntegrationMatchers();
env = new jasmineUnderTest.Env();
env.randomizeTests(false);
env.configure({random: false});
});
it('should assign spec ids sequentially', function() {
@@ -740,8 +740,7 @@ describe("spec running", function () {
it("should run the tests in a consistent order when a seed is supplied", function(done) {
var actions = [];
env.seed('123456');
env.randomizeTests(true);
env.configure({random: true, seed: '123456'});
env.beforeEach(function () {
actions.push('topSuite beforeEach');
@@ -865,7 +864,7 @@ describe("spec running", function () {
});
});
env.throwOnExpectationFailure(true);
env.configure({oneFailurePerSpec: true});
var assertions = function() {
expect(actions).toEqual([
@@ -900,7 +899,7 @@ describe("spec running", function () {
});
});
env.throwOnExpectationFailure(true);
env.configure({oneFailurePerSpec: true});
var assertions = function() {
expect(actions).toEqual([
@@ -932,6 +931,89 @@ describe("spec running", function () {
});
});
env.configure({oneFailurePerSpec: true});
var assertions = 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) {
var actions = [];
spyOn(env, 'deprecated');
env.describe('Something', function() {
env.beforeEach(function() {
actions.push('outer beforeEach');
throw new Error("error");
});
env.afterEach(function() {
actions.push('outer afterEach');
});
env.describe('Inner', function() {
env.beforeEach(function() {
actions.push('inner beforeEach');
});
env.afterEach(function() {
actions.push('inner afterEach');
});
env.it('does it' , function() {
actions.push('inner it');
});
});
});
env.throwOnExpectationFailure(true);
var assertions = function() {
expect(actions).toEqual([
'outer beforeEach',
'inner afterEach',
'outer afterEach'
]);
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) {
var actions = [];
spyOn(env, 'deprecated');
env.describe('Something', function() {
env.beforeEach(function(done) {
actions.push('beforeEach');
done.fail('error');
actions.push('after done.fail');
});
env.afterEach(function() {
actions.push('afterEach');
});
env.it('does it' , function() {
actions.push('it');
});
});
env.throwOnExpectationFailure(true);
var assertions = function() {
@@ -939,6 +1021,42 @@ describe("spec running", function () {
'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) {
var actions = [];
spyOn(env, 'deprecated');
env.describe('Something', function() {
env.beforeEach(function(innerDone) {
actions.push('beforeEach');
}, 1);
env.afterEach(function() {
actions.push('afterEach');
});
env.it('does it' , function() {
actions.push('it');
});
});
env.throwOnExpectationFailure(true);
var assertions = function() {
expect(actions).toEqual([
'beforeEach',
'afterEach'
]);
expect(env.deprecated).toHaveBeenCalled();
done();
};
@@ -965,8 +1083,7 @@ describe("spec running", function () {
});
});
env.randomizeTests(false);
env.stopOnSpecFailure(true);
env.configure({random: false, failFast: true});
var assertions = function() {
expect(actions).toEqual(['fails']);
@@ -976,5 +1093,36 @@ describe("spec running", function () {
env.addReporter({ jasmineDone: assertions });
env.execute();
});
it("does not run further specs when one fails when configured with deprecated option", function(done) {
var actions = [];
spyOn(env, 'deprecated');
env.describe('wrapper', function() {
env.it('fails', function() {
actions.push('fails');
env.expect(1).toBe(2);
});
});
env.describe('holder', function() {
env.it('does not run', function() {
actions.push('does not run');
});
});
env.configure({random: false});
env.stopOnSpecFailure(true);
var assertions = function() {
expect(actions).toEqual(['fails']);
expect(env.deprecated).toHaveBeenCalled();
done();
};
env.addReporter({ jasmineDone: assertions });
env.execute();
});
});
});