Skip to content

Commit

Permalink
refactor: update COVERAGE.md to accommodate ava-nesm.config.js
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed May 18, 2021
1 parent 9f83426 commit 77d71db
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-all-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ jobs:
# END-RESTORE-BOILERPLATE

- name: generate coverage for all tests
run: yarn test:all-c8
run: 'yarn test:c8-all || :'
- name: generate coverage/html reports
run: yarn c8 report --reporter=html-spa --reports-dir=coverage/html --temp-directory=coverage/tmp
- uses: actions/upload-artifact@v2
Expand Down
33 changes: 16 additions & 17 deletions COVERAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Caveat

Until each module can be migrated to support Node.js's builtin ESM
implementation (`NESM`), the coverage line numbers will be out-of-sync with
implementation (`nesm`), the coverage line numbers will be out-of-sync with
reality.

In addition, we will have to implement source maps in all of our
Expand All @@ -12,7 +12,7 @@ source-to-source transforms (such as `@agoric/bundle-source`,

## Reports

Coverage reports for the current main branch (whose packages support `NESM`) are
Coverage reports for the current main branch (whose packages support `nesm`) are
published by CI to: https://agoric-sdk-coverage.netlify.app

You can create a report in any package (including the top-level directory):
Expand All @@ -27,34 +27,33 @@ yarn c8 report --reporter=html-spa
open coverage/html/index.html
```

## NESM Support
## Node.js ESM Support

With the current `patches/esm+3.2.25.diff`, it is possible to migrate packages
to support both RESM (`-r esm`) and NESM. If an `agoric-sdk` package has
dependencies that support NESM, you can attempt to make it also support NESM by:
to support both resm (`-r esm`) and nesm (Node.js ESM Support). If an
`agoric-sdk` package has dependencies that support nesm, you can attempt to make
it also support nesm by:

1. Make the following changes to its `package.json` (omitting comments):
1. Create `ava-nesm.config.js` removing `"require": ["esm"]`:

```sh
../../scripts/ava-nesm.cjs > ava-nesm.config.js
```

2. Make the following changes to its `package.json` (omitting comments):

```json
{
// Enable NESM support.
// Enable nesm support.
"type": "module",
"scripts": {
// The following line enables coverage generation from the top.
"test:c8": "c8 $C8_OPTIONS ava",
},
"devDependencies": {
// Remove:
// "esm": "^3.2.25"
}
"ava": {
// Remove:
// "require": ["esm"]
"test:c8": "c8 $C8_OPTIONS ava --config=ava-nesm.config.js",
}
}
```

2. Test that it runs correctly with both `yarn test` and `yarn test:c8`.
3. Test that both `yarn test` and `yarn test:c8` run correctly.

## Planned Implementation

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"lint-check": "yarn workspaces run lint-check",
"lint": "yarn workspaces run lint-check",
"test": "ava",
"test:all-c8": "rm -rf coverage/tmp && C8_OPTIONS=\"--clean=false --temp-directory=$PWD/coverage/tmp\" lerna run test:c8 || :",
"test:c8-all": "rm -rf coverage/tmp && C8_OPTIONS=\"--clean=false --temp-directory=$PWD/coverage/tmp\" lerna run test:c8",
"test:xs": "yarn workspaces run test:xs",
"build": "yarn workspaces run build",
"postinstall": "patch-package",
Expand Down
6 changes: 6 additions & 0 deletions packages/swing-store-simple/ava-nesm.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default {
"files": [
"test/**/test-*.js"
],
"timeout": "2m"
};
8 changes: 6 additions & 2 deletions packages/swing-store-simple/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"scripts": {
"build": "exit 0",
"test": "ava",
"test:c8": "c8 $C8_OPTIONS ava",
"test:c8": "c8 $C8_OPTIONS ava --config=ava-nesm.config.js",
"test:xs": "exit 0",
"lint-fix": "eslint --fix '**/*.js'",
"lint-check": "eslint '**/*.js'"
Expand All @@ -22,7 +22,8 @@
"n-readlines": "^1.0.0"
},
"devDependencies": {
"ava": "^3.12.1"
"ava": "^3.12.1",
"esm": "^3.2.25"
},
"publishConfig": {
"access": "public"
Expand All @@ -31,6 +32,9 @@
"files": [
"test/**/test-*.js"
],
"require": [
"esm"
],
"timeout": "2m"
},
"eslintConfig": {
Expand Down

0 comments on commit 77d71db

Please sign in to comment.