Compare commits

..

5 Commits

Author SHA1 Message Date
Steve Gravrock
906f37fe52 Bump version to 3.99.1 2022-02-21 16:30:15 -08:00
Steve Gravrock
4a2b10998a Remove Safari 8 and 9 from CI matrix
These browsers are still nominally supported by Jasmine 3.x, but they no
longer work on Saucelabs.
2022-02-19 14:23:02 -08:00
Steve Gravrock
d8b2efe4d6 Downgrade jasmine-browser-runner for compatibility with IE 2022-02-19 14:21:35 -08:00
Steve Gravrock
9d9e8f0c17 Lint fixes 2022-02-19 12:33:19 -08:00
Steve Gravrock
4059ab7ba6 Don't report a deprecation when a promise is resolved to something
beforeEach(() => somePromiseReturningFn()) is likely a common idiom
and we don't want to treat it as an error.

* Fixes #1958
2022-02-19 12:28:47 -08:00
7 changed files with 135 additions and 8 deletions

View File

@@ -8656,7 +8656,10 @@ getJasmineRequireObj().QueueRunner = function(j$) {
maybeThenable = queueableFn.fn.call(self.userContext);
if (maybeThenable && j$.isFunction_(maybeThenable.then)) {
maybeThenable.then(next, onPromiseRejection);
maybeThenable.then(
wrapInPromiseResolutionHandler(next),
onPromiseRejection
);
completedSynchronously = false;
return { completedSynchronously: false };
}
@@ -8747,6 +8750,16 @@ getJasmineRequireObj().QueueRunner = function(j$) {
}
};
function wrapInPromiseResolutionHandler(fn) {
return function(maybeArg) {
if (j$.isError_(maybeArg)) {
fn(maybeArg);
} else {
fn();
}
};
}
return QueueRunner;
};
@@ -10749,5 +10762,5 @@ getJasmineRequireObj().UserContext = function(j$) {
};
getJasmineRequireObj().version = function() {
return '3.99.0';
return '3.99.1';
};

View File

@@ -4,6 +4,6 @@
#
module Jasmine
module Core
VERSION = "3.99.0"
VERSION = "3.99.1"
end
end

View File

@@ -1,7 +1,7 @@
{
"name": "jasmine-core",
"license": "MIT",
"version": "3.99.0",
"version": "3.99.1",
"repository": {
"type": "git",
"url": "https://github.com/jasmine/jasmine.git"
@@ -45,7 +45,7 @@
"grunt-css-url-embed": "^1.11.1",
"grunt-sass": "^3.0.2",
"jasmine": "^3.10.0",
"jasmine-browser-runner": "github:jasmine/jasmine-browser#main",
"jasmine-browser-runner": "^0.10.0",
"jsdom": "^15.0.0",
"load-grunt-tasks": "^4.0.0",
"prettier": "1.17.1",

22
release_notes/3.99.1.md Normal file
View File

@@ -0,0 +1,22 @@
# Jasmine Core 3.99.1 Release Notes
This release fixes a bug in 3.99.0, which incorrectly reported a deprecation
warning when a promise returned from a function passed to `it`, `beforeEach`,
etc was resolved to a value.
## Supported environments
jasmine-core 3.99.1 has been tested in the following environments.
| Environment | Supported versions |
|-------------------|--------------------|
| Node | 10, 12, 14, 16 |
| Safari | 10-14 |
| Chrome | 98 |
| Firefox | 97, 78, 68 |
| Edge | 98 |
| Internet Explorer | 10, 11 |
------
_Release Notes generated with _[Anchorman](http://github.com/infews/anchorman)_

View File

@@ -32,8 +32,6 @@ run_browser firefox 78
run_browser firefox 68
run_browser safari 14
run_browser safari 13
run_browser safari 9
run_browser safari 8
run_browser MicrosoftEdge latest
echo

View File

@@ -254,6 +254,87 @@ describe('QueueRunner', function() {
expect(queueableFn2.fn).toHaveBeenCalled();
});
});
describe('as a result of a promise', function() {
describe('and the argument is an Error', function() {
// Since promise support was added, Jasmine has failed specs that
// return a promise that resolves to an error. That's probably not
// the desired behavior but it's also not something we should change
// except on a major release and with a deprecation warning in
// advance.
it('explicitly fails and moves to the next function', function(done) {
jasmine.getEnv().requirePromises();
var err = new Error('foo'),
queueableFn1 = {
fn: function() {
// eslint-disable-next-line compat/compat
return Promise.resolve(err);
}
},
queueableFn2 = { fn: jasmine.createSpy('fn2') },
failFn = jasmine.createSpy('fail'),
queueRunner = new jasmineUnderTest.QueueRunner({
queueableFns: [queueableFn1, queueableFn2],
fail: failFn,
onComplete: function() {
expect(failFn).toHaveBeenCalledWith(err);
expect(queueableFn2.fn).toHaveBeenCalled();
done();
}
});
queueRunner.execute();
});
it('does not log a deprecation', function(done) {
jasmine.getEnv().requirePromises();
var err = new Error('foo'),
queueableFn1 = {
fn: function() {
// eslint-disable-next-line compat/compat
return Promise.resolve(err);
}
},
deprecated = jasmine.createSpy('deprecated'),
queueRunner = new jasmineUnderTest.QueueRunner({
queueableFns: [queueableFn1],
deprecated: deprecated,
onComplete: function() {
expect(deprecated).not.toHaveBeenCalled();
done();
}
});
queueRunner.execute();
});
});
describe('and the argument is not an Error', function() {
it('does not log a deprecation or report a failure', function(done) {
jasmine.getEnv().requirePromises();
var queueableFn1 = {
fn: function() {
// eslint-disable-next-line compat/compat
return Promise.resolve('not an error');
}
},
failFn = jasmine.createSpy('fail'),
deprecated = jasmine.createSpy('deprecated'),
queueRunner = new jasmineUnderTest.QueueRunner({
queueableFns: [queueableFn1],
deprecated: deprecated,
fail: failFn,
onComplete: function() {
expect(deprecated).not.toHaveBeenCalled();
expect(failFn).not.toHaveBeenCalled();
done();
}
});
queueRunner.execute();
});
});
});
});
it('does not cause an explicit fail if execution is being stopped', function() {

View File

@@ -196,7 +196,10 @@ getJasmineRequireObj().QueueRunner = function(j$) {
maybeThenable = queueableFn.fn.call(self.userContext);
if (maybeThenable && j$.isFunction_(maybeThenable.then)) {
maybeThenable.then(next, onPromiseRejection);
maybeThenable.then(
wrapInPromiseResolutionHandler(next),
onPromiseRejection
);
completedSynchronously = false;
return { completedSynchronously: false };
}
@@ -287,5 +290,15 @@ getJasmineRequireObj().QueueRunner = function(j$) {
}
};
function wrapInPromiseResolutionHandler(fn) {
return function(maybeArg) {
if (j$.isError_(maybeArg)) {
fn(maybeArg);
} else {
fn();
}
};
}
return QueueRunner;
};