Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Snapshot ecosystem support to surface changes as test passing indicator #7

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
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
14 changes: 7 additions & 7 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
steps:
- name: checkout self
uses: actions/checkout@v3
- name: checkout from endo ${{ github.event.client_payload.ref }}
- name: checkout from endo ${{ github.event.client_payload.ref || github.inputs.ref }}
uses: actions/checkout@v3
with:
repository: endojs/endo
Expand All @@ -24,17 +24,17 @@ jobs:
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
node-version: '16'
cache: 'npm'
- name: prepare local copy of SES
run: |
cd _ENDO_REPO_/packages/ses
yarn install
cd _ENDO_REPO_/
yarn
- name: setup and run the tests
run: |
cd test-imports
npm start
npm i -D --ignore-scripts ../_ENDO_REPO_/packages/ses
npm ci --ignore-scripts
npm i -D --ignore-scripts ../_ENDO_REPO_/packages/compartment-mapper
npm i -D --ignore-scripts ../_ENDO_REPO_/packages/ses
npm ls
npm test
npm ls ses
17 changes: 15 additions & 2 deletions test-imports/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ To execute tests, run:
npm test
```

Unless you've edited the test-\*.js files and enabled the `only` command, all individual tests are ignored (marked as failing) and a snapshot of test summary is the only enabled one. It allows you to focus on what changes to Endo impact ecosystem compatibility.

### Testing local instance

To test your local Endo, open `index.mjs` and switch the imports to your local path.
Expand All @@ -26,7 +28,10 @@ Example

```js
import '../../endo/packages/ses/index.js';
import { importLocation } from '../../endo/packages/compartment-mapper/index.js';
import {
importLocation,
makeBundle,
} from '../../endo/packages/compartment-mapper/index.js';
```

## Cases
Expand All @@ -36,6 +41,12 @@ Each dependency has test cases generated for it checking if it works in cjs and

You can manually add test cases to `test-imports/cases` and all files there will run.

### Snapshots

`__snapshots__` folder contains a snapshot of all test results as they're unrealistic to turn 100% green. It's a proxy for detecting changes in ecosystem suport. Might evolve into something more advanced.

For now, if snapshots test is failing, you manually verify if it's a regression or an improvement (or both)

### Adding cases

Default test cases are generated by running
Expand All @@ -45,7 +56,7 @@ npm run install-case 'packagename'
npm run generate-cases
```

Existing files will not be overwritten. To regenerate all cases from dependencies run `npm mrun generate-cases overwrite`
Existing files will not be overwritten. To regenerate all cases from dependencies run `npm run generate-cases overwrite`

### Test case format

Expand All @@ -57,6 +68,8 @@ A test case must export `expected` and `actual` - these two will be passed to Av
REJECTED cases can be solved by adding a transform. I'm not listing all cases of rejections because there's just too many
Scaffolding for these tests adds a transform to avoid the most common ones.

> This section might be outdated compared to actual results as some of the issues might get fixed in Endo.

## typescript

- triggers SES_HTML_COMMENT_REJECTED error from comments
Expand Down
290 changes: 290 additions & 0 deletions test-imports/__snapshots__/test-cjs.mjs.md

Large diffs are not rendered by default.

Binary file added test-imports/__snapshots__/test-cjs.mjs.snap
Binary file not shown.
290 changes: 290 additions & 0 deletions test-imports/__snapshots__/test-mjs.mjs.md

Large diffs are not rendered by default.

Binary file added test-imports/__snapshots__/test-mjs.mjs.snap
Binary file not shown.
2 changes: 1 addition & 1 deletion test-imports/cases/_babel_types.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion test-imports/cases/_babel_types.mjs

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions test-imports/cases/multiformats.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

const all = require('multiformats');
let def;
exports.name = 'multiformats';
exports.expected = {"*":{"type":"object","keys":["CID","bytes","digest","hasher","varint"]},"default":{"type":"undefined","keys":[]}};
exports.actual = {
'*': { type: typeof all, keys: Object.keys(all || {}).filter(a=>a).sort() },
default: { type: typeof def, keys: Object.keys(def || {}).filter(a=>a).sort() }
};
9 changes: 9 additions & 0 deletions test-imports/cases/multiformats.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

import * as all from 'multiformats';
let def;
export const name = 'multiformats';
export const expected = {"*":{"type":"object","keys":["CID","bytes","digest","hasher","varint"]},"default":{"type":"undefined","keys":[]}};
export const actual = {
'*': { type: typeof all, keys: Object.keys(all || {}).filter(a=>a).sort() },
default: { type: typeof def, keys: Object.keys(def || {}).filter(a=>a).sort() }
};
9 changes: 9 additions & 0 deletions test-imports/cases/react-dom.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

const all = require('react-dom');
let def;
exports.name = 'react-dom';
exports.expected = {"*":{"type":"object","keys":["__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED","createPortal","createRoot","findDOMNode","flushSync","hydrate","hydrateRoot","render","unmountComponentAtNode","unstable_batchedUpdates","unstable_renderSubtreeIntoContainer","version"]},"default":{"type":"undefined","keys":[]}};
exports.actual = {
'*': { type: typeof all, keys: Object.keys(all || {}).filter(a=>a).sort() },
default: { type: typeof def, keys: Object.keys(def || {}).filter(a=>a).sort() }
};
9 changes: 9 additions & 0 deletions test-imports/cases/react-dom.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

import * as all from 'react-dom';
import def from 'react-dom';
export const name = 'react-dom';
export const expected = {"*":{"type":"object","keys":["__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED","createPortal","createRoot","default","findDOMNode","flushSync","hydrate","hydrateRoot","render","unmountComponentAtNode","unstable_batchedUpdates","unstable_renderSubtreeIntoContainer","version"]},"default":{"type":"object","keys":["__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED","createPortal","createRoot","findDOMNode","flushSync","hydrate","hydrateRoot","render","unmountComponentAtNode","unstable_batchedUpdates","unstable_renderSubtreeIntoContainer","version"]}};
export const actual = {
'*': { type: typeof all, keys: Object.keys(all || {}).filter(a=>a).sort() },
default: { type: typeof def, keys: Object.keys(def || {}).filter(a=>a).sort() }
};
9 changes: 9 additions & 0 deletions test-imports/cases/which.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

const all = require('which');
let def;
exports.name = 'which';
exports.expected = {"*":{"type":"function","keys":["sync"]},"default":{"type":"undefined","keys":[]}};
exports.actual = {
'*': { type: typeof all, keys: Object.keys(all || {}).filter(a=>a).sort() },
default: { type: typeof def, keys: Object.keys(def || {}).filter(a=>a).sort() }
};
9 changes: 9 additions & 0 deletions test-imports/cases/which.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

import * as all from 'which';
import def from 'which';
export const name = 'which';
export const expected = {"*":{"type":"object","keys":["default"]},"default":{"type":"function","keys":["sync"]}};
export const actual = {
'*': { type: typeof all, keys: Object.keys(all || {}).filter(a=>a).sort() },
default: { type: typeof def, keys: Object.keys(def || {}).filter(a=>a).sort() }
};
Loading