From 524d051e65d66e4c0cf525769b220b7fc9d7a4cf Mon Sep 17 00:00:00 2001 From: rajsite Date: Sat, 1 Jun 2019 15:30:52 -0500 Subject: [PATCH] Fix makeTestPending to run in beforeEach Calling pending only works for beforeEach https://github.com/jasmine/jasmine/issues/1579 And the stopSpecOnExpectationFailure setting only works for node cli. Have to use oneFailurePerSpec for karma-jasmine: https://github.com/karma-runner/karma-jasmine/issues/218 --- test-it/karma/http/HttpDelete.Test.js | 5 ++++- test-it/karma/http/HttpGet.Test.js | 5 ++++- test-it/karma/http/HttpHead.Test.js | 5 ++++- test-it/karma/http/HttpPost.Test.js | 5 ++++- test-it/karma/http/HttpPut.Test.js | 5 ++++- test-it/karma/http/Timeout.Test.js | 15 +++++++++------ test-it/karma/http/httpCORS.Test.js | 11 +++++++++-- 7 files changed, 38 insertions(+), 13 deletions(-) diff --git a/test-it/karma/http/HttpDelete.Test.js b/test-it/karma/http/HttpDelete.Test.js index 1e3439341..04af519ca 100644 --- a/test-it/karma/http/HttpDelete.Test.js +++ b/test-it/karma/http/HttpDelete.Test.js @@ -35,7 +35,6 @@ describe('Performing a DELETE request', function () { }); beforeAll(async function () { - httpBinHelpers.makeTestPendingIfHttpBinOffline(); vireo = await vireoHelpers.createInstance(); }); @@ -43,6 +42,10 @@ describe('Performing a DELETE request', function () { vireo = undefined; }); + beforeEach(function () { + httpBinHelpers.makeTestPendingIfHttpBinOffline(); + }); + it('with a simple 200 response', function (done) { var runSlicesAsync = vireoRunner.rebootAndLoadVia(vireo, httpDeleteMethodViaUrl); var viPathParser = vireoRunner.createVIPathParser(vireo, 'MyVI'); diff --git a/test-it/karma/http/HttpGet.Test.js b/test-it/karma/http/HttpGet.Test.js index 1d20fb0d8..a57cd09a7 100644 --- a/test-it/karma/http/HttpGet.Test.js +++ b/test-it/karma/http/HttpGet.Test.js @@ -41,7 +41,6 @@ describe('Performing a GET request', function () { }); beforeAll(async function () { - httpBinHelpers.makeTestPendingIfHttpBinOffline(); vireo = await vireoHelpers.createInstance(); }); @@ -49,6 +48,10 @@ describe('Performing a GET request', function () { vireo = undefined; }); + beforeEach(function () { + httpBinHelpers.makeTestPendingIfHttpBinOffline(); + }); + it('with a simple 200 response', function (done) { var runSlicesAsync = vireoRunner.rebootAndLoadVia(vireo, httpGetMethodViaUrl); var viPathParser = vireoRunner.createVIPathParser(vireo, 'MyVI'); diff --git a/test-it/karma/http/HttpHead.Test.js b/test-it/karma/http/HttpHead.Test.js index 3d45b8c0b..109d464f2 100644 --- a/test-it/karma/http/HttpHead.Test.js +++ b/test-it/karma/http/HttpHead.Test.js @@ -34,7 +34,6 @@ describe('Performing a HEAD request', function () { }); beforeAll(async function () { - httpBinHelpers.makeTestPendingIfHttpBinOffline(); vireo = await vireoHelpers.createInstance(); }); @@ -42,6 +41,10 @@ describe('Performing a HEAD request', function () { vireo = undefined; }); + beforeEach(function () { + httpBinHelpers.makeTestPendingIfHttpBinOffline(); + }); + it('with a simple 200 response', function (done) { var runSlicesAsync = vireoRunner.rebootAndLoadVia(vireo, httpHeadMethodViaUrl); var viPathParser = vireoRunner.createVIPathParser(vireo, 'MyVI'); diff --git a/test-it/karma/http/HttpPost.Test.js b/test-it/karma/http/HttpPost.Test.js index 067e68758..a109998a6 100644 --- a/test-it/karma/http/HttpPost.Test.js +++ b/test-it/karma/http/HttpPost.Test.js @@ -35,7 +35,6 @@ describe('Performing a POST request', function () { }); beforeAll(async function () { - httpBinHelpers.makeTestPendingIfHttpBinOffline(); vireo = await vireoHelpers.createInstance(); }); @@ -43,6 +42,10 @@ describe('Performing a POST request', function () { vireo = undefined; }); + beforeEach(function () { + httpBinHelpers.makeTestPendingIfHttpBinOffline(); + }); + it('with a simple 200 response', function (done) { var runSlicesAsync = vireoRunner.rebootAndLoadVia(vireo, httpPostMethodViaUrl); var viPathParser = vireoRunner.createVIPathParser(vireo, 'MyVI'); diff --git a/test-it/karma/http/HttpPut.Test.js b/test-it/karma/http/HttpPut.Test.js index 852def929..31988ce9a 100644 --- a/test-it/karma/http/HttpPut.Test.js +++ b/test-it/karma/http/HttpPut.Test.js @@ -35,7 +35,6 @@ describe('Performing a PUT request', function () { }); beforeAll(async function () { - httpBinHelpers.makeTestPendingIfHttpBinOffline(); vireo = await vireoHelpers.createInstance(); }); @@ -43,6 +42,10 @@ describe('Performing a PUT request', function () { vireo = undefined; }); + beforeEach(function () { + httpBinHelpers.makeTestPendingIfHttpBinOffline(); + }); + it('with a simple 200 response', function (done) { var runSlicesAsync = vireoRunner.rebootAndLoadVia(vireo, httpPutMethodViaUrl); var viPathParser = vireoRunner.createVIPathParser(vireo, 'MyVI'); diff --git a/test-it/karma/http/Timeout.Test.js b/test-it/karma/http/Timeout.Test.js index 3fa6f103f..c141908e0 100644 --- a/test-it/karma/http/Timeout.Test.js +++ b/test-it/karma/http/Timeout.Test.js @@ -23,13 +23,7 @@ describe('Timeout test suite #Slow', function () { httpBinHelpers.queryHttpBinStatus(done); }); - beforeEach(function (done) { - // The timeout tests sometimes need a recovery period so perform a full get request and wait for it before continuing - httpBinHelpers.forceHttpBinQuery('get?show_env=1', done); - }); - beforeAll(async function () { - httpBinHelpers.makeTestPendingIfHttpBinOffline(); vireo = await vireoHelpers.createInstance(); }); @@ -37,6 +31,15 @@ describe('Timeout test suite #Slow', function () { vireo = undefined; }); + beforeEach(function () { + httpBinHelpers.makeTestPendingIfHttpBinOffline(); + }); + + beforeEach(function (done) { + // The timeout tests sometimes need a recovery period so perform a full get request and wait for it before continuing + httpBinHelpers.forceHttpBinQuery('get?show_env=1', done); + }); + it('GET method with timeout 0s times out with httpbin delay of 10s', function (done) { var timeout = 0; var timeoutEpsilon = 1000; diff --git a/test-it/karma/http/httpCORS.Test.js b/test-it/karma/http/httpCORS.Test.js index 2ac5269fc..ad001fe49 100644 --- a/test-it/karma/http/httpCORS.Test.js +++ b/test-it/karma/http/httpCORS.Test.js @@ -20,11 +20,18 @@ describe('Performing a CORS request', function () { httpBinHelpers.queryHttpBinStatus(done); }); - beforeEach(async function () { - httpBinHelpers.makeTestPendingIfHttpBinOffline(); + beforeAll(async function () { vireo = await vireoHelpers.createInstance(); }); + afterAll(function () { + vireo = undefined; + }); + + beforeEach(function () { + httpBinHelpers.makeTestPendingIfHttpBinOffline(); + }); + beforeEach(function (done) { httpBinHelpers.forceHttpBinQuery('cookies/set?FastestLandAnimal=cheetah', done); });