Converted integration specs to async/await
This commit is contained in:
@@ -494,7 +494,7 @@ describe('Env', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('creates an expectationFactory that uses the current custom equality testers and object formatters', function(done) {
|
it('creates an expectationFactory that uses the current custom equality testers and object formatters', async function() {
|
||||||
function customEqualityTester() {}
|
function customEqualityTester() {}
|
||||||
function customObjectFormatter() {}
|
function customObjectFormatter() {}
|
||||||
function prettyPrinter() {}
|
function prettyPrinter() {}
|
||||||
@@ -515,19 +515,17 @@ describe('Env', function() {
|
|||||||
expectationFactory('actual', specInstance);
|
expectationFactory('actual', specInstance);
|
||||||
});
|
});
|
||||||
|
|
||||||
env.execute(null, function() {
|
await env.execute();
|
||||||
expect(jasmineUnderTest.makePrettyPrinter).toHaveBeenCalledWith([
|
expect(jasmineUnderTest.makePrettyPrinter).toHaveBeenCalledWith([
|
||||||
customObjectFormatter
|
customObjectFormatter
|
||||||
]);
|
]);
|
||||||
expect(jasmineUnderTest.MatchersUtil).toHaveBeenCalledWith({
|
expect(jasmineUnderTest.MatchersUtil).toHaveBeenCalledWith({
|
||||||
customTesters: [customEqualityTester],
|
customTesters: [customEqualityTester],
|
||||||
pp: prettyPrinter
|
pp: prettyPrinter
|
||||||
});
|
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('creates an asyncExpectationFactory that uses the current custom equality testers and object formatters', function(done) {
|
it('creates an asyncExpectationFactory that uses the current custom equality testers and object formatters', async function() {
|
||||||
function customEqualityTester() {}
|
function customEqualityTester() {}
|
||||||
function customObjectFormatter() {}
|
function customObjectFormatter() {}
|
||||||
function prettyPrinter() {}
|
function prettyPrinter() {}
|
||||||
@@ -548,15 +546,14 @@ describe('Env', function() {
|
|||||||
asyncExpectationFactory('actual', specInstance);
|
asyncExpectationFactory('actual', specInstance);
|
||||||
});
|
});
|
||||||
|
|
||||||
env.execute(null, function() {
|
await env.execute();
|
||||||
expect(jasmineUnderTest.makePrettyPrinter).toHaveBeenCalledWith([
|
|
||||||
customObjectFormatter
|
expect(jasmineUnderTest.makePrettyPrinter).toHaveBeenCalledWith([
|
||||||
]);
|
customObjectFormatter
|
||||||
expect(jasmineUnderTest.MatchersUtil).toHaveBeenCalledWith({
|
]);
|
||||||
customTesters: [customEqualityTester],
|
expect(jasmineUnderTest.MatchersUtil).toHaveBeenCalledWith({
|
||||||
pp: prettyPrinter
|
customTesters: [customEqualityTester],
|
||||||
});
|
pp: prettyPrinter
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ describe('Exceptions:', function() {
|
|||||||
env.cleanup_();
|
env.cleanup_();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should handle exceptions thrown, but continue', function(done) {
|
it('should handle exceptions thrown, but continue', async function() {
|
||||||
const secondTest = jasmine.createSpy('second test');
|
const secondTest = jasmine.createSpy('second test');
|
||||||
env.describe('Suite for handles exceptions', function() {
|
env.describe('Suite for handles exceptions', function() {
|
||||||
env.it(
|
env.it(
|
||||||
@@ -24,15 +24,12 @@ describe('Exceptions:', function() {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
const expectations = function() {
|
await env.execute();
|
||||||
expect(secondTest).toHaveBeenCalled();
|
|
||||||
done();
|
|
||||||
};
|
|
||||||
|
|
||||||
env.execute(null, expectations);
|
expect(secondTest).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should handle exceptions thrown directly in top-level describe blocks and continue', function(done) {
|
it('should handle exceptions thrown directly in top-level describe blocks and continue', async function() {
|
||||||
const secondDescribe = jasmine
|
const secondDescribe = jasmine
|
||||||
.createSpy('second describe')
|
.createSpy('second describe')
|
||||||
.and.callFake(function() {
|
.and.callFake(function() {
|
||||||
@@ -47,11 +44,8 @@ describe('Exceptions:', function() {
|
|||||||
});
|
});
|
||||||
env.describe("a suite that doesn't throw an exception", secondDescribe);
|
env.describe("a suite that doesn't throw an exception", secondDescribe);
|
||||||
|
|
||||||
const expectations = function() {
|
await env.execute();
|
||||||
expect(secondDescribe).toHaveBeenCalled();
|
|
||||||
done();
|
|
||||||
};
|
|
||||||
|
|
||||||
env.execute(null, expectations);
|
expect(secondDescribe).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ describe('Custom Async Matchers (Integration)', function() {
|
|||||||
env.cleanup_();
|
env.cleanup_();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('passes the spec if the custom async matcher passes', function(done) {
|
it('passes the spec if the custom async matcher passes', async function() {
|
||||||
env.it('spec using custom async matcher', function() {
|
env.it('spec using custom async matcher', function() {
|
||||||
env.addAsyncMatchers({
|
env.addAsyncMatchers({
|
||||||
toBeReal: function() {
|
toBeReal: function() {
|
||||||
@@ -30,10 +30,10 @@ describe('Custom Async Matchers (Integration)', function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
env.addReporter({ specDone: specExpectations });
|
env.addReporter({ specDone: specExpectations });
|
||||||
env.execute(null, done);
|
await env.execute();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('uses the negative compare function for a negative comparison, if provided', function(done) {
|
it('uses the negative compare function for a negative comparison, if provided', async function() {
|
||||||
env.it('spec with custom negative comparison matcher', function() {
|
env.it('spec with custom negative comparison matcher', function() {
|
||||||
env.addAsyncMatchers({
|
env.addAsyncMatchers({
|
||||||
toBeReal: function() {
|
toBeReal: function() {
|
||||||
@@ -56,10 +56,10 @@ describe('Custom Async Matchers (Integration)', function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
env.addReporter({ specDone: specExpectations });
|
env.addReporter({ specDone: specExpectations });
|
||||||
env.execute(null, done);
|
await env.execute();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('generates messages with the same rules as built in matchers absent a custom message', function(done) {
|
it('generates messages with the same rules as built in matchers absent a custom message', async function() {
|
||||||
env.it('spec with an expectation', function() {
|
env.it('spec with an expectation', function() {
|
||||||
env.addAsyncMatchers({
|
env.addAsyncMatchers({
|
||||||
toBeReal: function() {
|
toBeReal: function() {
|
||||||
@@ -81,10 +81,10 @@ describe('Custom Async Matchers (Integration)', function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
env.addReporter({ specDone: specExpectations });
|
env.addReporter({ specDone: specExpectations });
|
||||||
env.execute(null, done);
|
await env.execute();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('passes the jasmine utility to the matcher factory', function(done) {
|
it('passes the jasmine utility to the matcher factory', async function() {
|
||||||
const matcherFactory = function() {
|
const matcherFactory = function() {
|
||||||
return {
|
return {
|
||||||
compare: function() {
|
compare: function() {
|
||||||
@@ -112,10 +112,10 @@ describe('Custom Async Matchers (Integration)', function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
env.addReporter({ specDone: specExpectations });
|
env.addReporter({ specDone: specExpectations });
|
||||||
env.execute(null, done);
|
await env.execute();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('provides custom equality testers to the matcher factory via matchersUtil', function(done) {
|
it('provides custom equality testers to the matcher factory via matchersUtil', async function() {
|
||||||
const matcherFactory = function(matchersUtil) {
|
const matcherFactory = function(matchersUtil) {
|
||||||
return {
|
return {
|
||||||
compare: function(actual, expected) {
|
compare: function(actual, expected) {
|
||||||
@@ -146,6 +146,6 @@ describe('Custom Async Matchers (Integration)', function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
env.addReporter({ specDone: specExpectations });
|
env.addReporter({ specDone: specExpectations });
|
||||||
env.execute(null, done);
|
await env.execute();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -30,7 +30,7 @@ describe('spec running', function() {
|
|||||||
expect(it4.id).toEqual('spec4');
|
expect(it4.id).toEqual('spec4');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('nested suites', function(done) {
|
it('nested suites', async function() {
|
||||||
let foo = 0;
|
let foo = 0;
|
||||||
let bar = 0;
|
let bar = 0;
|
||||||
let baz = 0;
|
let baz = 0;
|
||||||
@@ -61,16 +61,15 @@ describe('spec running', function() {
|
|||||||
expect(baz).toEqual(0);
|
expect(baz).toEqual(0);
|
||||||
expect(quux).toEqual(0);
|
expect(quux).toEqual(0);
|
||||||
|
|
||||||
env.execute(null, function() {
|
await env.execute();
|
||||||
expect(foo).toEqual(1);
|
|
||||||
expect(bar).toEqual(1);
|
expect(foo).toEqual(1);
|
||||||
expect(baz).toEqual(1);
|
expect(bar).toEqual(1);
|
||||||
expect(quux).toEqual(1);
|
expect(baz).toEqual(1);
|
||||||
done();
|
expect(quux).toEqual(1);
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should permit nested describes', function(done) {
|
it('should permit nested describes', async function() {
|
||||||
const actions = [];
|
const actions = [];
|
||||||
|
|
||||||
env.beforeEach(function() {
|
env.beforeEach(function() {
|
||||||
@@ -127,42 +126,41 @@ describe('spec running', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
env.execute(null, function() {
|
await env.execute();
|
||||||
const expected = [
|
|
||||||
'topSuite beforeEach',
|
|
||||||
'outer beforeEach',
|
|
||||||
'outer it 1',
|
|
||||||
'outer afterEach',
|
|
||||||
'topSuite afterEach',
|
|
||||||
|
|
||||||
'topSuite beforeEach',
|
const expected = [
|
||||||
'outer beforeEach',
|
'topSuite beforeEach',
|
||||||
'inner 1 beforeEach',
|
'outer beforeEach',
|
||||||
'inner 1 it',
|
'outer it 1',
|
||||||
'inner 1 afterEach',
|
'outer afterEach',
|
||||||
'outer afterEach',
|
'topSuite afterEach',
|
||||||
'topSuite afterEach',
|
|
||||||
|
|
||||||
'topSuite beforeEach',
|
'topSuite beforeEach',
|
||||||
'outer beforeEach',
|
'outer beforeEach',
|
||||||
'outer it 2',
|
'inner 1 beforeEach',
|
||||||
'outer afterEach',
|
'inner 1 it',
|
||||||
'topSuite afterEach',
|
'inner 1 afterEach',
|
||||||
|
'outer afterEach',
|
||||||
|
'topSuite afterEach',
|
||||||
|
|
||||||
'topSuite beforeEach',
|
'topSuite beforeEach',
|
||||||
'outer beforeEach',
|
'outer beforeEach',
|
||||||
'inner 2 beforeEach',
|
'outer it 2',
|
||||||
'inner 2 it',
|
'outer afterEach',
|
||||||
'inner 2 afterEach',
|
'topSuite afterEach',
|
||||||
'outer afterEach',
|
|
||||||
'topSuite afterEach'
|
'topSuite beforeEach',
|
||||||
];
|
'outer beforeEach',
|
||||||
expect(actions).toEqual(expected);
|
'inner 2 beforeEach',
|
||||||
done();
|
'inner 2 it',
|
||||||
});
|
'inner 2 afterEach',
|
||||||
|
'outer afterEach',
|
||||||
|
'topSuite afterEach'
|
||||||
|
];
|
||||||
|
expect(actions).toEqual(expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should run multiple befores and afters ordered so functions declared later are treated as more specific', function(done) {
|
it('should run multiple befores and afters ordered so functions declared later are treated as more specific', async function() {
|
||||||
const actions = [];
|
const actions = [];
|
||||||
|
|
||||||
env.beforeAll(function() {
|
env.beforeAll(function() {
|
||||||
@@ -219,28 +217,27 @@ describe('spec running', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
env.execute(null, function() {
|
await env.execute();
|
||||||
const expected = [
|
|
||||||
'runner beforeAll1',
|
const expected = [
|
||||||
'runner beforeAll2',
|
'runner beforeAll1',
|
||||||
'runner beforeEach1',
|
'runner beforeAll2',
|
||||||
'runner beforeEach2',
|
'runner beforeEach1',
|
||||||
'beforeEach1',
|
'runner beforeEach2',
|
||||||
'beforeEach2',
|
'beforeEach1',
|
||||||
'outer it 1',
|
'beforeEach2',
|
||||||
'afterEach2',
|
'outer it 1',
|
||||||
'afterEach1',
|
'afterEach2',
|
||||||
'runner afterEach2',
|
'afterEach1',
|
||||||
'runner afterEach1',
|
'runner afterEach2',
|
||||||
'runner afterAll2',
|
'runner afterEach1',
|
||||||
'runner afterAll1'
|
'runner afterAll2',
|
||||||
];
|
'runner afterAll1'
|
||||||
expect(actions).toEqual(expected);
|
];
|
||||||
done();
|
expect(actions).toEqual(expected);
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should run beforeAlls before beforeEachs and afterAlls after afterEachs', function(done) {
|
it('should run beforeAlls before beforeEachs and afterAlls after afterEachs', async function() {
|
||||||
const actions = [];
|
const actions = [];
|
||||||
|
|
||||||
env.beforeAll(function() {
|
env.beforeAll(function() {
|
||||||
@@ -281,24 +278,23 @@ describe('spec running', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
env.execute(null, function() {
|
await env.execute();
|
||||||
const expected = [
|
|
||||||
'runner beforeAll',
|
const expected = [
|
||||||
'inner beforeAll',
|
'runner beforeAll',
|
||||||
'runner beforeEach',
|
'inner beforeAll',
|
||||||
'inner beforeEach',
|
'runner beforeEach',
|
||||||
'it',
|
'inner beforeEach',
|
||||||
'inner afterEach',
|
'it',
|
||||||
'runner afterEach',
|
'inner afterEach',
|
||||||
'inner afterAll',
|
'runner afterEach',
|
||||||
'runner afterAll'
|
'inner afterAll',
|
||||||
];
|
'runner afterAll'
|
||||||
expect(actions).toEqual(expected);
|
];
|
||||||
done();
|
expect(actions).toEqual(expected);
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should run beforeAlls and afterAlls in the order declared when runnablesToRun is provided', function(done) {
|
it('should run beforeAlls and afterAlls in the order declared when runnablesToRun is provided', async function() {
|
||||||
const actions = [];
|
const actions = [];
|
||||||
let spec;
|
let spec;
|
||||||
let spec2;
|
let spec2;
|
||||||
@@ -345,30 +341,29 @@ describe('spec running', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
env.execute([spec2.id, spec.id], function() {
|
await env.execute([spec2.id, spec.id]);
|
||||||
const expected = [
|
|
||||||
'runner beforeAll',
|
|
||||||
'inner beforeAll',
|
|
||||||
'runner beforeEach',
|
|
||||||
'inner beforeEach',
|
|
||||||
'it2',
|
|
||||||
'inner afterEach',
|
|
||||||
'runner afterEach',
|
|
||||||
|
|
||||||
'runner beforeEach',
|
const expected = [
|
||||||
'inner beforeEach',
|
'runner beforeAll',
|
||||||
'it',
|
'inner beforeAll',
|
||||||
'inner afterEach',
|
'runner beforeEach',
|
||||||
'runner afterEach',
|
'inner beforeEach',
|
||||||
'inner afterAll',
|
'it2',
|
||||||
'runner afterAll'
|
'inner afterEach',
|
||||||
];
|
'runner afterEach',
|
||||||
expect(actions).toEqual(expected);
|
|
||||||
done();
|
'runner beforeEach',
|
||||||
});
|
'inner beforeEach',
|
||||||
|
'it',
|
||||||
|
'inner afterEach',
|
||||||
|
'runner afterEach',
|
||||||
|
'inner afterAll',
|
||||||
|
'runner afterAll'
|
||||||
|
];
|
||||||
|
expect(actions).toEqual(expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('only runs *Alls once in a focused suite', function(done) {
|
it('only runs *Alls once in a focused suite', async function() {
|
||||||
const actions = [];
|
const actions = [];
|
||||||
|
|
||||||
env.fdescribe('Suite', function() {
|
env.fdescribe('Suite', function() {
|
||||||
@@ -383,14 +378,13 @@ describe('spec running', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
env.execute(null, function() {
|
await env.execute();
|
||||||
expect(actions).toEqual(['beforeAll', 'spec', 'afterAll']);
|
|
||||||
done();
|
expect(actions).toEqual(['beforeAll', 'spec', 'afterAll']);
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('focused runnables', function() {
|
describe('focused runnables', function() {
|
||||||
it('runs the relevant alls and eachs for each runnable', function(done) {
|
it('runs the relevant alls and eachs for each runnable', async function() {
|
||||||
const actions = [];
|
const actions = [];
|
||||||
env.beforeAll(function() {
|
env.beforeAll(function() {
|
||||||
actions.push('beforeAll');
|
actions.push('beforeAll');
|
||||||
@@ -417,24 +411,23 @@ describe('spec running', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
env.execute(null, function() {
|
await env.execute();
|
||||||
const expected = [
|
|
||||||
'beforeAll',
|
|
||||||
'beforeEach',
|
|
||||||
'spec in fdescribe',
|
|
||||||
'afterEach',
|
|
||||||
|
|
||||||
'beforeEach',
|
const expected = [
|
||||||
'focused spec',
|
'beforeAll',
|
||||||
'afterEach',
|
'beforeEach',
|
||||||
'afterAll'
|
'spec in fdescribe',
|
||||||
];
|
'afterEach',
|
||||||
expect(actions).toEqual(expected);
|
|
||||||
done();
|
'beforeEach',
|
||||||
});
|
'focused spec',
|
||||||
|
'afterEach',
|
||||||
|
'afterAll'
|
||||||
|
];
|
||||||
|
expect(actions).toEqual(expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('focused specs in focused suites cause non-focused siblings to not run', function(done) {
|
it('focused specs in focused suites cause non-focused siblings to not run', async function() {
|
||||||
const actions = [];
|
const actions = [];
|
||||||
|
|
||||||
env.fdescribe('focused suite', function() {
|
env.fdescribe('focused suite', function() {
|
||||||
@@ -446,14 +439,13 @@ describe('spec running', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
env.execute(null, function() {
|
await env.execute();
|
||||||
const expected = ['focused spec'];
|
|
||||||
expect(actions).toEqual(expected);
|
const expected = ['focused spec'];
|
||||||
done();
|
expect(actions).toEqual(expected);
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('focused suites in focused suites cause non-focused siblings to not run', function(done) {
|
it('focused suites in focused suites cause non-focused siblings to not run', async function() {
|
||||||
const actions = [];
|
const actions = [];
|
||||||
|
|
||||||
env.fdescribe('focused suite', function() {
|
env.fdescribe('focused suite', function() {
|
||||||
@@ -467,14 +459,13 @@ describe('spec running', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
env.execute(null, function() {
|
await env.execute();
|
||||||
const expected = ['inner spec'];
|
|
||||||
expect(actions).toEqual(expected);
|
const expected = ['inner spec'];
|
||||||
done();
|
expect(actions).toEqual(expected);
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('focused runnables unfocus ancestor focused suites', function(done) {
|
it('focused runnables unfocus ancestor focused suites', async function() {
|
||||||
const actions = [];
|
const actions = [];
|
||||||
|
|
||||||
env.fdescribe('focused suite', function() {
|
env.fdescribe('focused suite', function() {
|
||||||
@@ -488,15 +479,14 @@ describe('spec running', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
env.execute(null, function() {
|
await env.execute();
|
||||||
const expected = ['focused spec'];
|
|
||||||
expect(actions).toEqual(expected);
|
const expected = ['focused spec'];
|
||||||
done();
|
expect(actions).toEqual(expected);
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("shouldn't run disabled suites", function(done) {
|
it("shouldn't run disabled suites", async function() {
|
||||||
const specInADisabledSuite = jasmine.createSpy('specInADisabledSuite');
|
const specInADisabledSuite = jasmine.createSpy('specInADisabledSuite');
|
||||||
env.describe('A Suite', function() {
|
env.describe('A Suite', function() {
|
||||||
env.xdescribe('with a disabled suite', function() {
|
env.xdescribe('with a disabled suite', function() {
|
||||||
@@ -504,13 +494,12 @@ describe('spec running', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
env.execute(null, function() {
|
await env.execute();
|
||||||
expect(specInADisabledSuite).not.toHaveBeenCalled();
|
|
||||||
done();
|
expect(specInADisabledSuite).not.toHaveBeenCalled();
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("shouldn't run before/after functions in disabled suites", function(done) {
|
it("shouldn't run before/after functions in disabled suites", async function() {
|
||||||
const shouldNotRun = jasmine.createSpy('shouldNotRun');
|
const shouldNotRun = jasmine.createSpy('shouldNotRun');
|
||||||
env.xdescribe('A disabled Suite', function() {
|
env.xdescribe('A disabled Suite', function() {
|
||||||
// None of the before/after functions should run.
|
// None of the before/after functions should run.
|
||||||
@@ -522,13 +511,12 @@ describe('spec running', function() {
|
|||||||
env.it('spec inside a disabled suite', shouldNotRun);
|
env.it('spec inside a disabled suite', shouldNotRun);
|
||||||
});
|
});
|
||||||
|
|
||||||
env.execute(null, function() {
|
await env.execute();
|
||||||
expect(shouldNotRun).not.toHaveBeenCalled();
|
|
||||||
done();
|
expect(shouldNotRun).not.toHaveBeenCalled();
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should allow top level suites to be disabled', function(done) {
|
it('should allow top level suites to be disabled', async function() {
|
||||||
const specInADisabledSuite = jasmine.createSpy('specInADisabledSuite'),
|
const specInADisabledSuite = jasmine.createSpy('specInADisabledSuite'),
|
||||||
otherSpec = jasmine.createSpy('otherSpec');
|
otherSpec = jasmine.createSpy('otherSpec');
|
||||||
|
|
||||||
@@ -539,14 +527,13 @@ describe('spec running', function() {
|
|||||||
env.it('another spec', otherSpec);
|
env.it('another spec', otherSpec);
|
||||||
});
|
});
|
||||||
|
|
||||||
env.execute(null, function() {
|
await env.execute();
|
||||||
expect(specInADisabledSuite).not.toHaveBeenCalled();
|
|
||||||
expect(otherSpec).toHaveBeenCalled();
|
expect(specInADisabledSuite).not.toHaveBeenCalled();
|
||||||
done();
|
expect(otherSpec).toHaveBeenCalled();
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should set all pending specs to pending when a suite is run', function(done) {
|
it('should set all pending specs to pending when a suite is run', async function() {
|
||||||
env.describe('default current suite', function() {
|
env.describe('default current suite', function() {
|
||||||
env.it('I am a pending spec');
|
env.it('I am a pending spec');
|
||||||
});
|
});
|
||||||
@@ -554,17 +541,16 @@ describe('spec running', function() {
|
|||||||
|
|
||||||
env.addReporter(reporter);
|
env.addReporter(reporter);
|
||||||
|
|
||||||
env.execute(null, function() {
|
await env.execute();
|
||||||
expect(reporter.specDone).toHaveBeenCalledWith(
|
|
||||||
jasmine.objectContaining({
|
expect(reporter.specDone).toHaveBeenCalledWith(
|
||||||
status: 'pending'
|
jasmine.objectContaining({
|
||||||
})
|
status: 'pending'
|
||||||
);
|
})
|
||||||
done();
|
);
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should recover gracefully when there are errors in describe functions', function(done) {
|
it('should recover gracefully when there are errors in describe functions', async function() {
|
||||||
const specs = [],
|
const specs = [],
|
||||||
reporter = jasmine.createSpyObj(['specDone', 'suiteDone']);
|
reporter = jasmine.createSpyObj(['specDone', 'suiteDone']);
|
||||||
|
|
||||||
@@ -599,24 +585,23 @@ describe('spec running', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
env.addReporter(reporter);
|
env.addReporter(reporter);
|
||||||
env.execute(null, function() {
|
await env.execute();
|
||||||
expect(specs).toEqual([
|
|
||||||
'outer1 inner1 should thingy',
|
expect(specs).toEqual([
|
||||||
'outer1 inner2 should other thingy',
|
'outer1 inner1 should thingy',
|
||||||
'outer2 should xxx'
|
'outer1 inner2 should other thingy',
|
||||||
]);
|
'outer2 should xxx'
|
||||||
expect(reporter.suiteDone).toHaveFailedExpectationsForRunnable(
|
]);
|
||||||
'outer1 inner1',
|
expect(reporter.suiteDone).toHaveFailedExpectationsForRunnable(
|
||||||
[/inner error/]
|
'outer1 inner1',
|
||||||
);
|
[/inner error/]
|
||||||
expect(reporter.suiteDone).toHaveFailedExpectationsForRunnable('outer1', [
|
);
|
||||||
/outer error/
|
expect(reporter.suiteDone).toHaveFailedExpectationsForRunnable('outer1', [
|
||||||
]);
|
/outer error/
|
||||||
done();
|
]);
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('re-enters suites that have no *Alls', function(done) {
|
it('re-enters suites that have no *Alls', async function() {
|
||||||
const actions = [];
|
const actions = [];
|
||||||
let spec1;
|
let spec1;
|
||||||
let spec2;
|
let spec2;
|
||||||
@@ -636,10 +621,9 @@ describe('spec running', function() {
|
|||||||
actions.push('spec3');
|
actions.push('spec3');
|
||||||
});
|
});
|
||||||
|
|
||||||
env.execute([spec2.id, spec3.id, spec1.id], function() {
|
await env.execute([spec2.id, spec3.id, spec1.id]);
|
||||||
expect(actions).toEqual(['spec2', 'spec3', 'spec1']);
|
|
||||||
done();
|
expect(actions).toEqual(['spec2', 'spec3', 'spec1']);
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('refuses to re-enter suites with a beforeAll', function() {
|
it('refuses to re-enter suites with a beforeAll', function() {
|
||||||
@@ -698,7 +682,7 @@ describe('spec running', function() {
|
|||||||
expect(actions).toEqual([]);
|
expect(actions).toEqual([]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should run the tests in a consistent order when a seed is supplied', function(done) {
|
it('should run the tests in a consistent order when a seed is supplied', async function() {
|
||||||
const actions = [];
|
const actions = [];
|
||||||
env.configure({ random: true, seed: '123456' });
|
env.configure({ random: true, seed: '123456' });
|
||||||
|
|
||||||
@@ -756,39 +740,38 @@ describe('spec running', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
env.execute(null, function() {
|
await env.execute();
|
||||||
const expected = [
|
|
||||||
'topSuite beforeEach',
|
|
||||||
'outer beforeEach',
|
|
||||||
'outer it 2',
|
|
||||||
'outer afterEach',
|
|
||||||
'topSuite afterEach',
|
|
||||||
|
|
||||||
'topSuite beforeEach',
|
const expected = [
|
||||||
'outer beforeEach',
|
'topSuite beforeEach',
|
||||||
'inner 2 beforeEach',
|
'outer beforeEach',
|
||||||
'inner 2 it',
|
'outer it 2',
|
||||||
'inner 2 afterEach',
|
'outer afterEach',
|
||||||
'outer afterEach',
|
'topSuite afterEach',
|
||||||
'topSuite afterEach',
|
|
||||||
|
|
||||||
'topSuite beforeEach',
|
'topSuite beforeEach',
|
||||||
'outer beforeEach',
|
'outer beforeEach',
|
||||||
'inner 1 beforeEach',
|
'inner 2 beforeEach',
|
||||||
'inner 1 it',
|
'inner 2 it',
|
||||||
'inner 1 afterEach',
|
'inner 2 afterEach',
|
||||||
'outer afterEach',
|
'outer afterEach',
|
||||||
'topSuite afterEach',
|
'topSuite afterEach',
|
||||||
|
|
||||||
'topSuite beforeEach',
|
'topSuite beforeEach',
|
||||||
'outer beforeEach',
|
'outer beforeEach',
|
||||||
'outer it 1',
|
'inner 1 beforeEach',
|
||||||
'outer afterEach',
|
'inner 1 it',
|
||||||
'topSuite afterEach'
|
'inner 1 afterEach',
|
||||||
];
|
'outer afterEach',
|
||||||
expect(actions).toEqual(expected);
|
'topSuite afterEach',
|
||||||
done();
|
|
||||||
});
|
'topSuite beforeEach',
|
||||||
|
'outer beforeEach',
|
||||||
|
'outer it 1',
|
||||||
|
'outer afterEach',
|
||||||
|
'topSuite afterEach'
|
||||||
|
];
|
||||||
|
expect(actions).toEqual(expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
function hasStandardErrorHandlingBehavior() {
|
function hasStandardErrorHandlingBehavior() {
|
||||||
@@ -1298,7 +1281,7 @@ describe('spec running', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('when stopOnSpecFailure is on', function() {
|
describe('when stopOnSpecFailure is on', function() {
|
||||||
it('does not run further specs when one fails', function(done) {
|
it('does not run further specs when one fails', async function() {
|
||||||
const actions = [];
|
const actions = [];
|
||||||
|
|
||||||
env.describe('wrapper', function() {
|
env.describe('wrapper', function() {
|
||||||
@@ -1317,10 +1300,9 @@ describe('spec running', function() {
|
|||||||
env.configure({ random: false });
|
env.configure({ random: false });
|
||||||
env.configure({ stopOnSpecFailure: true });
|
env.configure({ stopOnSpecFailure: true });
|
||||||
|
|
||||||
env.execute(null, function() {
|
await env.execute();
|
||||||
expect(actions).toEqual(['fails']);
|
|
||||||
done();
|
expect(actions).toEqual(['fails']);
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('runs afterAll functions', async function() {
|
it('runs afterAll functions', async function() {
|
||||||
@@ -1364,7 +1346,7 @@ describe('spec running', function() {
|
|||||||
env.configure({ autoCleanClosures: false, random: false });
|
env.configure({ autoCleanClosures: false, random: false });
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to run multiple times', function(done) {
|
it('should be able to run multiple times', async function() {
|
||||||
const actions = [];
|
const actions = [];
|
||||||
|
|
||||||
env.describe('Suite', function() {
|
env.describe('Suite', function() {
|
||||||
@@ -1378,16 +1360,14 @@ describe('spec running', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
env.execute(null, function() {
|
await env.execute();
|
||||||
expect(actions).toEqual(['spec1', 'spec2']);
|
expect(actions).toEqual(['spec1', 'spec2']);
|
||||||
env.execute(null, function() {
|
|
||||||
expect(actions).toEqual(['spec1', 'spec2', 'spec1', 'spec2']);
|
await env.execute();
|
||||||
done();
|
expect(actions).toEqual(['spec1', 'spec2', 'spec1', 'spec2']);
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should reset results between runs', function(done) {
|
it('should reset results between runs', async function() {
|
||||||
const specResults = {};
|
const specResults = {};
|
||||||
const suiteResults = {};
|
const suiteResults = {};
|
||||||
let firstExecution = true;
|
let firstExecution = true;
|
||||||
@@ -1440,48 +1420,46 @@ describe('spec running', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
env.execute(null, function() {
|
await env.execute();
|
||||||
expect(specResults).toEqual({
|
expect(specResults).toEqual({
|
||||||
spec1: 'failed',
|
spec1: 'failed',
|
||||||
spec2: 'pending',
|
spec2: 'pending',
|
||||||
spec3: 'pending',
|
spec3: 'pending',
|
||||||
spec4: 'failed',
|
spec4: 'failed',
|
||||||
spec5: 'failed',
|
spec5: 'failed',
|
||||||
spec6: 'pending',
|
spec6: 'pending',
|
||||||
spec7: 'pending'
|
spec7: 'pending'
|
||||||
});
|
});
|
||||||
expect(suiteResults).toEqual({
|
expect(suiteResults).toEqual({
|
||||||
suite0: 'passed',
|
suite0: 'passed',
|
||||||
suite1: 'passed',
|
suite1: 'passed',
|
||||||
suite2: 'passed',
|
suite2: 'passed',
|
||||||
suite3: 'passed',
|
suite3: 'passed',
|
||||||
suite4: 'pending',
|
suite4: 'pending',
|
||||||
suite5: 'passed'
|
suite5: 'passed'
|
||||||
});
|
});
|
||||||
env.execute(null, function() {
|
|
||||||
expect(specResults).toEqual({
|
await env.execute();
|
||||||
spec1: 'passed',
|
expect(specResults).toEqual({
|
||||||
spec2: 'passed',
|
spec1: 'passed',
|
||||||
spec3: 'pending',
|
spec2: 'passed',
|
||||||
spec4: 'passed',
|
spec3: 'pending',
|
||||||
spec5: 'failed',
|
spec4: 'passed',
|
||||||
spec6: 'pending',
|
spec5: 'failed',
|
||||||
spec7: 'pending'
|
spec6: 'pending',
|
||||||
});
|
spec7: 'pending'
|
||||||
expect(suiteResults).toEqual({
|
});
|
||||||
suite0: 'passed',
|
expect(suiteResults).toEqual({
|
||||||
suite1: 'passed',
|
suite0: 'passed',
|
||||||
suite2: 'passed',
|
suite1: 'passed',
|
||||||
suite3: 'passed',
|
suite2: 'passed',
|
||||||
suite4: 'pending',
|
suite3: 'passed',
|
||||||
suite5: 'passed'
|
suite4: 'pending',
|
||||||
});
|
suite5: 'passed'
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should execute before and after hooks per run', function(done) {
|
it('should execute before and after hooks per run', async function() {
|
||||||
let timeline = [];
|
let timeline = [];
|
||||||
const timelineFn = function(hookName) {
|
const timelineFn = function(hookName) {
|
||||||
return function() {
|
return function() {
|
||||||
@@ -1507,17 +1485,15 @@ describe('spec running', function() {
|
|||||||
env.it('spec1', timelineFn('spec1'));
|
env.it('spec1', timelineFn('spec1'));
|
||||||
env.it('spec2', timelineFn('spec2'));
|
env.it('spec2', timelineFn('spec2'));
|
||||||
});
|
});
|
||||||
env.execute(null, function() {
|
await env.execute();
|
||||||
expect(timeline).toEqual(expectedTimeLine);
|
expect(timeline).toEqual(expectedTimeLine);
|
||||||
timeline = [];
|
|
||||||
env.execute(null, function() {
|
timeline = [];
|
||||||
expect(timeline).toEqual(expectedTimeLine);
|
await env.execute();
|
||||||
done();
|
expect(timeline).toEqual(expectedTimeLine);
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to filter out different tests in subsequent runs', function(done) {
|
it('should be able to filter out different tests in subsequent runs', async function() {
|
||||||
const specResults = {};
|
const specResults = {};
|
||||||
let focussedSpec = 'spec1';
|
let focussedSpec = 'spec1';
|
||||||
|
|
||||||
@@ -1539,29 +1515,27 @@ describe('spec running', function() {
|
|||||||
env.it('spec3', function() {});
|
env.it('spec3', function() {});
|
||||||
});
|
});
|
||||||
|
|
||||||
env.execute(null, function() {
|
await env.execute();
|
||||||
expect(specResults).toEqual({
|
expect(specResults).toEqual({
|
||||||
spec1: 'passed',
|
spec1: 'passed',
|
||||||
spec2: 'excluded',
|
spec2: 'excluded',
|
||||||
spec3: 'excluded'
|
spec3: 'excluded'
|
||||||
});
|
});
|
||||||
focussedSpec = 'spec2';
|
|
||||||
env.execute(null, function() {
|
focussedSpec = 'spec2';
|
||||||
expect(specResults).toEqual({
|
await env.execute();
|
||||||
spec1: 'excluded',
|
expect(specResults).toEqual({
|
||||||
spec2: 'passed',
|
spec1: 'excluded',
|
||||||
spec3: 'excluded'
|
spec2: 'passed',
|
||||||
});
|
spec3: 'excluded'
|
||||||
focussedSpec = 'spec3';
|
});
|
||||||
env.execute(null, function() {
|
|
||||||
expect(specResults).toEqual({
|
focussedSpec = 'spec3';
|
||||||
spec1: 'excluded',
|
await env.execute();
|
||||||
spec2: 'excluded',
|
expect(specResults).toEqual({
|
||||||
spec3: 'passed'
|
spec1: 'excluded',
|
||||||
});
|
spec2: 'excluded',
|
||||||
done();
|
spec3: 'passed'
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user