Use test plan for compartment tests
MODIFY
packages/ses/test/import-gauntlet.test.js
packages/ses/test/import-gauntlet.test.js
@@ -8,6 +8,8 @@ import { resolveNode, makeNodeImporter } from './node.js';
const { test } = tap;
test('import for side effect', async t => {
+ t.plan(0);
+
const makeImportHook = makeNodeImporter({
'https://example.com/import-for-side-effect.js': `
// empty
@@ -27,11 +29,11 @@ test('import for side effect', async t => {
);
await compartment.import('./main.js');
-
- t.end();
});
test('import all from module', async t => {
+ t.plan(2);
+
const makeImportHook = makeNodeImporter({
'https://example.com/import-all-from-me.js': `
export const a = 10;
@@ -56,11 +58,11 @@ test('import all from module', async t => {
t.equal(namespace.default.a, 10);
t.equal(namespace.default.b, 20);
-
- t.end();
});
test('import named exports from me', async t => {
+ t.plan(2);
+
const makeImportHook = makeNodeImporter({
'https://example.com/import-named-exports-from-me.js': `
export const fizz = 10;
@@ -85,11 +87,11 @@ test('import named exports from me', async t => {
t.equal(namespace.default.fizz, 10);
t.equal(namespace.default.buzz, 20);
-
- t.end();
});
test('import all from module', async t => {
+ t.plan(1);
+
const makeImportHook = makeNodeImporter({
'https://example.com/import-named-export-and-rename.js': `
export const color = 'blue';
@@ -112,11 +114,11 @@ test('import all from module', async t => {
const { namespace } = await compartment.import('./main.js');
t.equal(namespace.color, 'blue');
-
- t.end();
});
test('import and reexport', async t => {
+ t.plan(1);
+
const makeImportHook = makeNodeImporter({
'https://example.com/import-and-reexport-name-from-me.js': `
export const qux = 42;
@@ -138,11 +140,11 @@ test('import and reexport', async t => {
const { namespace } = await compartment.import('./main.js');
t.equal(namespace.qux, 42);
-
- t.end();
});
test('import and export all', async t => {
+ t.plan(2);
+
const makeImportHook = makeNodeImporter({
'https://example.com/import-and-export-all-from-me.js': `
export const alpha = 0;
@@ -166,11 +168,11 @@ test('import and export all', async t => {
t.equal(namespace.alpha, 0);
t.equal(namespace.omega, 23);
-
- t.end();
});
test('live binding', async t => {
+ t.plan(1);
+
const makeImportHook = makeNodeImporter({
'https://example.com/import-live-export.js': `
export let quuux = null;

MODIFY
packages/ses/test/import-stack-traces.test.js
packages/ses/test/import-stack-traces.test.js
@@ -5,6 +5,12 @@ import { resolveNode, makeNodeImporter } from './node.js';
const { test } = tap;
test('preserve file names in stack traces', async t => {
+ if (new Error().stack != null) {
+ t.plan(1);
+ } else {
+ t.plan(0);
+ }
+
const makeImportHook = makeNodeImporter({
'https://example.com/packages/erroneous/main.js': `
throw new Error("threw an error");
@@ -36,6 +42,4 @@ test('preserve file names in stack traces', async t => {
'stack trace contains file name of emitting module',
);
}
-
- t.end();
});

MODIFY
packages/ses/test/import.test.js
packages/ses/test/import.test.js
// These tests exercise the Compartment import interface and linkage
// between compartments, and Compartment endowments.
+/* eslint max-lines: 0 */
+
import tap from 'tap';
import { Compartment } from '../src/main.js';
import { resolveNode, makeNodeImporter } from './node.js';
@@ -12,6 +14,8 @@ const { test } = tap;
// that uses fully qualified URLs as module specifiers and module locations,
// not distinguishing one from the other.
test('import within one compartment, web resolution', async t => {
+ t.plan(1);
+
const retrieve = makeStaticRetriever({
'https://example.com/packages/example/half.js': `
export default 21;
@@ -49,6 +53,8 @@ test('import within one compartment, web resolution', async t => {
// This case demonstrates the same arrangement except that the Compartment uses
// Node.js module specifier resolution.
test('import within one compartment, node resolution', async t => {
+ t.plan(1);
+
const makeImportHook = makeNodeImporter({
'https://example.com/packages/example/half.js': `
export default 21;
@@ -80,6 +86,8 @@ test('import within one compartment, node resolution', async t => {
// This demonstrates a pair of linked Node.js compartments.
test('two compartments, three modules, one endowment', async t => {
+ t.plan(1);
+
const makeImportHook = makeNodeImporter({
'https://example.com/packages/example/half.js': `
if (typeof double !== 'undefined') {
@@ -134,7 +142,7 @@ test('two compartments, three modules, one endowment', async t => {
});
test('module exports namespace as an object', async t => {
- t.plan(6);
+ t.plan(7);
const makeImportHook = makeNodeImporter({
'https://example.com/packages/meaning/main.js': `
@@ -156,6 +164,12 @@ test('module exports namespace as an object', async t => {
const { namespace } = await compartment.import('./main.js');
+ t.equals(
+ namespace.meaning,
+ 42,
+ 'exported constant must have a namespace property',
+ );
+
t.throws(() => {
namespace.alternateMeaning = 10;
}, /^Cannot set property/);
@@ -184,6 +198,8 @@ test('module exports namespace as an object', async t => {
});
test('modules are memoized', async t => {
+ t.plan(1);
+
const makeImportHook = makeNodeImporter({
'https://example.com/packages/example/c-s-lewis.js': `
export const entity = {};
@@ -219,10 +235,11 @@ test('modules are memoized', async t => {
const { clive, clerk } = namespace;
t.ok(clive === clerk, 'diamond dependency must refer to the same module');
- t.end();
});
test('compartments with same sources do not share instances', async t => {
+ t.plan(1);
+
const makeImportHook = makeNodeImporter({
'https://example.com/packages/arm/main.js': `
export default {};
@@ -263,5 +280,4 @@ test('compartments with same sources do not share instances', async t => {
leftArm !== rightArm,
'different compartments with same sources do not share instances',
);
- t.end();
});

Use test plan for compartment tests (#316)