Jasmine 3: Replace usage of Spec#after
diff --git a/src/legacy-exec/test/test/propertyreplacer.js b/src/legacy-exec/test/test/propertyreplacer.js
index 57f7c34..89da92a 100644
--- a/src/legacy-exec/test/test/propertyreplacer.js
+++ b/src/legacy-exec/test/test/propertyreplacer.js
@@ -19,25 +19,24 @@
  *
 */
 
+/* eslint-env jasmine */
+
 // Use this helper module to stub out properties within Jasmine tests.
 // Original values will be restored after each test.
 
-var curStubs = null;
+var stubs = [];
 
 function removeAllStubs () {
-    for (var i = curStubs.length - 1, stub; stub = curStubs[i]; --i) { // eslint-disable-line no-cond-assign
+    for (const stub of stubs) {
         stub.obj[stub.key] = stub.value;
     }
-    curStubs = null;
+    stubs = [];
 }
 
-exports.stub = function (obj, key, value) {
-    if (!curStubs) {
-        curStubs = [];
-        jasmine.getEnv().currentSpec.after(removeAllStubs); // eslint-disable-line no-undef
-    }
+afterEach(removeAllStubs);
 
-    curStubs.push({
+exports.stub = function (obj, key, value) {
+    stubs.push({
         obj: obj,
         key: key,
         value: obj[key]
diff --git a/test/test.modulemapper.js b/test/test.modulemapper.js
index 8d86707..b862a97 100644
--- a/test/test.modulemapper.js
+++ b/test/test.modulemapper.js
@@ -167,19 +167,15 @@
         expect(modulemapper.getOriginalSymbol(context, 'obj.str')).toBe(context.obj.str);
     });
     it('Test#017 : should log about deprecated property access', function () {
-        var origConsoleLog = console.log;
-        console.log = jasmine.createSpy('console.log');
-        this.after(function () {
-            console.log = origConsoleLog;
-        });
+        spyOn(console, 'log');
         modulemapper.clobbers('cordova/test/testmodule', 'obj', 'Use foo instead');
         modulemapper.defaults('cordova/test/testmodule', 'newProp', 'Use foo instead');
         modulemapper.mapModules(context);
         context.obj.func();
         context.obj.func();
-        expect(console.log.callCount).toBe(1);
+        expect(console.log).toHaveBeenCalledTimes(1);
         context.newProp.func();
         context.newProp.func();
-        expect(console.log.callCount).toBe(2);
+        expect(console.log).toHaveBeenCalledTimes(2);
     });
 });
diff --git a/test/test.urlutil.js b/test/test.urlutil.js
index d21ad4c..6b245b1 100644
--- a/test/test.urlutil.js
+++ b/test/test.urlutil.js
@@ -53,12 +53,13 @@
         var baseTag = document.createElement('base');
         baseTag.href = rootUrl;
         document.head.appendChild(baseTag);
-        this.after(function () {
+        try {
+            expect(urlutil.makeAbsolute('foo?a#b')).toBe(rootUrl + 'foo?a#b');
+            expect(urlutil.makeAbsolute('foo/b%20ar')).toBe(rootUrl + 'foo/b%20ar');
+            testRootRelative(rootUrl);
+        } finally {
             document.head.removeChild(baseTag);
-        });
-        expect(urlutil.makeAbsolute('foo?a#b')).toBe(rootUrl + 'foo?a#b');
-        expect(urlutil.makeAbsolute('foo/b%20ar')).toBe(rootUrl + 'foo/b%20ar');
-        testRootRelative(rootUrl);
+        }
     });
 
     it('Test#005 : can handle scheme-relative URLs', function () {