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

replace mocha and nyc with oletus and c8 #64

Merged
merged 1 commit into from
Dec 27, 2023
Merged
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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
/.nyc_output/
/coverage/
/node_modules/
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ Many variables have default values and are therefore optional.
| `license-file` | `LICENSE` | The name of the licence file. |
| `source-files` | `index.js` | Space-separated list of filenames. Globbing is supported (with `globstar`). |
| `readme-source-files` | `index.js` | Space-separated list of filenames. Globbing is supported (with `globstar`). |
| `test-files` | `test/**/*.js` | Space-separated list of filenames. Globbing is supported (with `globstar`). |
| `heading-level` | `4` | The `<h[1-6]>` level of headings transcribed from `heading-prefix` comments. |
| `heading-prefix` | `#` | The character which follows `//` to signify a heading to transcribe. |
| `comment-prefix` | `.` | The character which follows `//` to signify documentation to transcribe. |
Expand Down Expand Up @@ -153,8 +154,8 @@ Runs the following linters:
- [`lint-package-json`][]
- [`lint-commit-messages`][]

Configurable via [variables][] (`source-files` and those respected by the
aforementioned linters).
Configurable via [variables][] (`source-files`, `test-files`, and those
respected by the aforementioned linters).

### `lint-commit-messages`

Expand Down Expand Up @@ -197,11 +198,10 @@ Configurable via [variables][] (`repo-owner`, `repo-name`, `default-branch`,

### `test`

Runs the project's [Mocha↗︎][] test suite via [Istanbul↗︎][] and asserts that the
test suite satisfies the project's coverage requirements.
Runs [`oletus`↗︎][] via [`c8`↗︎][] to run the project's test suite and assert
that it satisfies the project's coverage requirements.

Configurable via [variables][] (`min-branch-coverage`) and the `mocha` field of
__package.json__.
Configurable via [variables][] (`min-branch-coverage`, `test-files`).

### `update-copyright-year`

Expand All @@ -226,9 +226,9 @@ Configurable via [variables][] (`author-name`, `license-file`).
[custom scripts]: #custom-scripts
[variables]: #variables

[Istanbul↗︎]: https://istanbul.js.org/
[Mocha↗︎]: https://mochajs.org/
[`c8`↗︎]: https://github.com/bcoe/c8
[`doctest`↗︎]: https://github.com/davidchambers/doctest
[`eslint`↗︎]: https://eslint.org/
[`oletus`↗︎]: https://github.com/bearror/oletus
[`transcribe`↗︎]: https://github.com/plaid/transcribe
[`xyz`↗︎]: https://github.com/davidchambers/xyz
6 changes: 4 additions & 2 deletions bin/lint
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ run_custom_script lint "$@"

set +f ; shopt -s globstar nullglob
# shellcheck disable=SC2207
files=($(get source-files))
source_files=($(get source-files))
# shellcheck disable=SC2207
test_files=($(get test-files))
set -f ; shopt -u globstar nullglob

if [[ "${PUBLISHING-false}" == true ]] ; then
Expand All @@ -20,6 +22,6 @@ run check-required-files
node_modules/.bin/eslint \
--no-error-on-unmatched-pattern \
--report-unused-disable-directives \
-- "${files[@]}" '*.{js,mjs}' 'test/**/*.{js,mjs}'
-- "${source_files[@]}" '*.{js,mjs}' "${test_files[@]}"
run lint-package-json
run lint-commit-messages
29 changes: 18 additions & 11 deletions bin/test
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,21 @@ run_custom_script test "$@"

branches="$(get min-branch-coverage)"

node_modules/.bin/nyc \
--check-coverage \
--branches "$branches" \
--functions 0 \
--lines 0 \
--statements 0 \
--reporter text \
--reporter html \
--extension .js \
--extension .mjs \
-- node_modules/.bin/mocha
set +f ; shopt -s globstar nullglob
# shellcheck disable=SC2207
source_files=($(get source-files))
# shellcheck disable=SC2207
test_files=($(get test-files))
set -f ; shopt -u globstar nullglob

args=(
--check-coverage
--branches "$branches"
--functions 0
--lines 0
--statements 0
)
for name in "${source_files[@]}" ; do
args+=(--include "$name")
done
node_modules/.bin/c8 "${args[@]}" -- node_modules/.bin/oletus -- "${test_files[@]}"
1 change: 1 addition & 0 deletions functions
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ get() {
license-file) printf 'LICENSE' ;;
source-files) printf 'index.js' ;;
readme-source-files) printf 'index.js' ;;
test-files) printf 'test/**/*.js' ;;
heading-level) printf '4' ;;
heading-prefix) printf '#' ;;
comment-prefix) printf '.' ;;
Expand Down
7 changes: 2 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@
"npm": ">=3.0.0"
},
"dependencies": {
"c8": "8.0.x",
"doctest": "0.21.x",
"eslint": "8.55.x",
"mocha": "8.x.x",
"nyc": "15.x.x",
"oletus": "4.0.x",
"sanctuary-style": "7.0.x",
"spdx-expression-parse": "3.0.x",
"transcribe": "1.1.2",
Expand All @@ -48,8 +48,5 @@
"lint": "bin/lint",
"release": "bin/release",
"test": "npm run lint && bin/test && npm run doctest"
},
"mocha": {
"ui": "tdd"
}
}
2 changes: 2 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import assert from 'node:assert';

import test from 'oletus';

import {identity} from '../index.js';


Expand Down