fix(integration-test): report an unhandled rejection (not file://)
Note that for browsers, you need to use imported code or scripts
served from the same origin, and not file://... in order to see
the unhandled rejection reports.
Node.js works fine.
MODIFY
packages/ses-integration-test/package.json
packages/ses-integration-test/package.json
},
"ava": {
"files": [
- "*test*/**/test-*.js"
+ "*test*/**/test-*.js",
+ "*test*/**/test-*.mjs"
],
"require": []
},

DELETE
packages/ses-integration-test/test/test-sanity.js
-import test from 'tape';
-
-import 'ses';
-
-test('sanity', t => {
- t.equal(lockdown(), undefined, 'lockdown runs successfully');
- const c = new Compartment({ abc: 456 });
- t.equal(c.evaluate('123'), 123, 'simple evaluate succeeds');
- t.equal(c.evaluate('abc'), 456, 'endowment succeeds');
- t.end();
-});

ADD
packages/ses-integration-test/test/test-sanity.mjs
+/* global setTimeout */
+import test from 'tape';
+
+import 'ses';
+
+test('sanity', t => {
+ t.equal(lockdown(), undefined, 'lockdown runs successfully');
+ const c = new Compartment({ abc: 456 });
+ t.equal(c.evaluate('123'), 123, 'simple evaluate succeeds');
+ t.equal(c.evaluate('abc'), 456, 'endowment succeeds');
+ t.end();
+});
+
+test('promise rejection logs', async t => {
+ t.plan(3);
+
+ // Test the promise rejection logging system.
+ // We expect this to log a message to the console when GC runs.
+ Promise.reject(
+ Error(
+ 'this unhandled rejection should be logged with SES_UNHANDLED_REJECTION',
+ ),
+ );
+
+ await Promise.reject(
+ Error('this handled rejection should NOT be logged'),
+ ).catch(e =>
+ t.equal(e.message, 'this handled rejection should NOT be logged'),
+ );
+ t.ok(true, 'delaying for 1000ms');
+ {
+ // Reject a promise, then handle it much later (a whole 1000ms).
+ const r = Promise.reject(
+ Error('this async-handled rejection should NOT be logged'),
+ );
+ setTimeout(async () => {
+ await r.catch(e =>
+ t.equal(
+ e.message,
+ 'this async-handled rejection should NOT be logged',
+ 'async-handled rejection',
+ ),
+ );
+ t.end();
+ }, 1000);
+ }
+});

MODIFY
packages/ses-integration-test/transform-tests/config/rollup.config.cjs.js
packages/ses-integration-test/transform-tests/config/rollup.config.cjs.js
@@ -5,7 +5,7 @@ import commonjs from '@rollup/plugin-commonjs';
export default [
{
input: {
- include: ['test/**/*.js'],
+ include: ['test/**/*.js', 'test/**/*.mjs'],
},
output: {
file: 'transform-tests/output/test.cjs.js',

MODIFY
packages/ses-integration-test/transform-tests/config/rollup.config.esm.js
packages/ses-integration-test/transform-tests/config/rollup.config.esm.js
@@ -5,7 +5,7 @@ import commonjs from '@rollup/plugin-commonjs';
export default [
{
input: {
- include: ['test/**/*.js'],
+ include: ['test/**/*.js', 'test/**/*.mjs'],
exclude: ['test/test-require.js'],
},
output: {

MODIFY
packages/ses-integration-test/transform-tests/config/rollup.config.no-lib.js
packages/ses-integration-test/transform-tests/config/rollup.config.no-lib.js
@@ -6,7 +6,7 @@ import commonjs from '@rollup/plugin-commonjs';
export default [
{
input: {
- include: ['test/**/*.js'],
+ include: ['test/**/*.js', 'test/**/*.mjs'],
},
output: {
file: 'transform-tests/output/test.no-lib.cjs.js',

MODIFY
scripts/build-post-release-test.sh
scripts/build-post-release-test.sh
@@ -4,6 +4,6 @@ DIR=$(dirname -- "${BASH_SOURCE[0]}")
cd "$DIR/.."
npm run-script build
cd packages/ses-integration-test
-npm install --no-save "$( npm pack ../ses | tail -1 )"
+npm install --no-save --legacy-peer-deps "$( npm pack ../ses | tail -1 )"
npm run create-test-file-no-lib-cjs
npm run create-test-file-browserified-tape

MODIFY
scripts/build-pre-release-test.sh
scripts/build-pre-release-test.sh
@@ -4,7 +4,7 @@ DIR=$(dirname -- "${BASH_SOURCE[0]}")
cd "$DIR/.."
npm run-script build
cd packages/ses-integration-test
-npm install --no-save "$( npm pack ../ses | tail -1 )"
+npm install --no-save --legacy-peer-deps "$( npm pack ../ses | tail -1 )"
npm run create-test-file-no-lib-cjs
npm run create-test-file-esm
npm run create-test-file-cjs

fix(integration-test): report an unhandled rejection (not file://)

Note that for browsers, you need to use imported code or scripts
served from the same origin, and not file://... in order to see
the unhandled rejection reports.

Node.js works fine.