Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions packages/compartment-mapper/test/e2e-module-types.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import test from 'ava';
import { spawnSync } from 'node:child_process';
import { fileURLToPath } from 'node:url';

const fixtures = ['i1.cjs', 'i1.mjs', 'i2.cjs', 'i2.mjs'];

const fixtureLocation = fileURLToPath(
new URL('./fixtures-e2e-module-types', import.meta.url),
);

for (const entry of fixtures) {
test(`Compare endo and node module loading of ${entry}`, async t => {
console.log('Running test with entry:', entry);

const nodeOutput = spawnSync(process.execPath, [`./${entry}`], {
encoding: 'utf8',
cwd: fixtureLocation,
});
const endoOutput = spawnSync(process.execPath, ['endo.js', `./${entry}`], {
encoding: 'utf8',
cwd: fixtureLocation,
});

if (nodeOutput.error) {
throw nodeOutput.error;
}
if (endoOutput.error) {
throw endoOutput.error;
}

t.log(`Node stdout:\n${nodeOutput.stdout}`);
t.log(`Endo stdout:\n${endoOutput.stdout}`);

if (nodeOutput.status !== 0) {
t.log(`Node stderr:\n${nodeOutput.stderr}`);
}
if (endoOutput.status !== 0) {
t.log(`Endo stderr:\n${endoOutput.stderr}`);
}

t.is(nodeOutput.stdout, endoOutput.stdout, `expected matching results`);

// t.snapshot(
// {
// node: nodeOutput.stdout,
// endo: endoOutput.stdout,
// },
// `output for ${entry}`,
// );
});
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import result from "depth1"
console.dir(result, { depth: null })
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "module"
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const result = require('depth1');
console.dir(result, { depth: null });
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "commonjs"
}
17 changes: 17 additions & 0 deletions packages/compartment-mapper/test/fixtures-e2e-module-types/endo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import 'ses';
import fs from 'fs';
import url from 'url';
import { importLocation } from '../../src/import.js';
import { makeReadPowers } from '../../src/node-powers.js';

const readPowers = makeReadPowers({ fs, url });
const { read } = readPowers;

const arg1 = process.argv[2];

const location = new URL(arg1, import.meta.url).toString();

importLocation(read, location, {
globals: { console },
});

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const result = require('depth1');
console.dir(result, { depth: null });
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import result from "depth1"
console.dir(result, { depth: null })
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require('./app/index.js')
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import './app-esm/index.js';

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "e2e-module-types",
"version": "1.0.0",
"type": "module",
"dependencies": {
"depth1": "^1.0.0",
"depth2": "^1.0.0",
"depth2cjs": "^1.0.0",
"depth2esm": "^1.0.0",
"depth3": "^1.0.0",
"depth3from2": "^1.0.0",
"depth3from2cjs": "^1.0.0",
"depth3from2esm": "^1.0.0"
},
"scripts": {
"preinstall": "echo DO NOT INSTALL TEST FIXTURES; exit -1"
},
"license": "ISC"
}
Loading