From 09ce3a30b6dcf481eb7a5b2bc5916910a5ca98e0 Mon Sep 17 00:00:00 2001 From: Steve Gravrock Date: Sat, 30 Aug 2025 12:58:04 -0700 Subject: [PATCH] Pend environment-specific specs rather than passing --- spec/core/baseSpec.js | 3 +-- spec/core/buildExpectationResultSpec.js | 2 +- spec/core/matchers/matchersUtilSpec.js | 35 +++++++------------------ spec/core/matchers/toThrowErrorSpec.js | 2 +- 4 files changed, 13 insertions(+), 29 deletions(-) diff --git a/spec/core/baseSpec.js b/spec/core/baseSpec.js index 4910109e..a656d3f4 100644 --- a/spec/core/baseSpec.js +++ b/spec/core/baseSpec.js @@ -2,8 +2,7 @@ describe('base helpers', function() { describe('isError_', function() { it('correctly handles WebSocket events', function(done) { if (typeof jasmine.getGlobal().WebSocket === 'undefined') { - done(); - return; + pending('Environment does not provide WebSocket'); } const obj = (function() { diff --git a/spec/core/buildExpectationResultSpec.js b/spec/core/buildExpectationResultSpec.js index 8b667594..a47ff1cb 100644 --- a/spec/core/buildExpectationResultSpec.js +++ b/spec/core/buildExpectationResultSpec.js @@ -79,7 +79,7 @@ describe('buildExpectationResult', function() { it('handles nodejs assertions', function() { if (typeof require === 'undefined') { - return; + pending('This test only runs in Node'); } const assert = require('assert'); const value = 8421; diff --git a/spec/core/matchers/matchersUtilSpec.js b/spec/core/matchers/matchersUtilSpec.js index 27460933..747fca59 100644 --- a/spec/core/matchers/matchersUtilSpec.js +++ b/spec/core/matchers/matchersUtilSpec.js @@ -250,10 +250,6 @@ describe('matchersUtil', function() { }); it('passes for equivalent Promises (GitHub issue #1314)', function() { - if (typeof Promise === 'undefined') { - return; - } - const p1 = new Promise(function() {}), p2 = new Promise(function() {}), matchersUtil = new jasmineUnderTest.MatchersUtil(); @@ -263,14 +259,13 @@ describe('matchersUtil', function() { }); describe('when running in a browser', function() { - function isNotRunningInBrowser() { - return typeof document === 'undefined'; - } + beforeEach(function() { + if (typeof document === 'undefined') { + pending('This test only runs in browsers'); + } + }); it('passes for equivalent DOM nodes', function() { - if (isNotRunningInBrowser()) { - return; - } const a = document.createElement('div'); const matchersUtil = new jasmineUnderTest.MatchersUtil(); @@ -285,9 +280,6 @@ describe('matchersUtil', function() { }); it('passes for equivalent objects from different frames', function() { - if (isNotRunningInBrowser()) { - return; - } const matchersUtil = new jasmineUnderTest.MatchersUtil(); const iframe = document.createElement('iframe'); document.body.appendChild(iframe); @@ -299,9 +291,6 @@ describe('matchersUtil', function() { }); it('fails for DOM nodes with different attributes or child nodes', function() { - if (isNotRunningInBrowser()) { - return; - } const matchersUtil = new jasmineUnderTest.MatchersUtil(); const a = document.createElement('div'); a.setAttribute('test-attr', 'attr-value'); @@ -325,14 +314,13 @@ describe('matchersUtil', function() { }); describe('when running in Node', function() { - function isNotRunningInNode() { - return typeof require !== 'function'; - } + beforeEach(function() { + if (typeof require !== 'function') { + pending('This test only runs in Node'); + } + }); it('passes for equivalent objects from different vm contexts', function() { - if (isNotRunningInNode()) { - return; - } const matchersUtil = new jasmineUnderTest.MatchersUtil(); const vm = require('vm'); const sandbox = { @@ -344,9 +332,6 @@ describe('matchersUtil', function() { }); it('passes for equivalent arrays from different vm contexts', function() { - if (isNotRunningInNode()) { - return; - } const matchersUtil = new jasmineUnderTest.MatchersUtil(); const vm = require('vm'); const sandbox = { diff --git a/spec/core/matchers/toThrowErrorSpec.js b/spec/core/matchers/toThrowErrorSpec.js index a3c967c5..3e7e528c 100644 --- a/spec/core/matchers/toThrowErrorSpec.js +++ b/spec/core/matchers/toThrowErrorSpec.js @@ -82,7 +82,7 @@ describe('toThrowError', function() { it('passes if thrown is an instanceof Error regardless of global that contains its constructor', function() { if (isNotRunningInBrowser()) { - return; + pending('This test only runs in browsers.'); } const matcher = jasmineUnderTest.matchers.toThrowError();