diff --git a/README.md b/README.md index 3f66214..5990b01 100644 --- a/README.md +++ b/README.md @@ -93,6 +93,70 @@ Note the use of `incremental: true`, which speed up compilation massively. * `--ignore` or `-i`, ignore a glob pattern, and not look for tests there * `--expose-gc`, exposes the gc() function to tests * `--pattern` or `-p`, run tests matching the given glob pattern +* `--reporter` or `-r`, set up a reporter, use a colon to set a file destination. Default: `spec`. + +## Reporters + +Here are the available reporters: + +* `md`: creates a markdown table, useful for setting up a Summary in your GitHub Action +* `gh`: emits `::error` workflow commands for GitHub Actions to show inlined error. Enabled by default when running on GHA. +* `tap`: outputs the test results in the TAP format. +* `spec`: outputs the test results in a human-readable format. +* `dot`: outputs the test results in a compact format, where each passing test is represented by a ., and each failing test is represented by a X. +* `junit`: outputs test results in a jUnit XML format + +## GitHub Action Summary + +The following will automatically show the summary of the test run in the summary page of GitHub Actions. + +```yaml +name: ci + +on: + push: + paths-ignore: + - 'docs/**' + - '*.md' + pull_request: + paths-ignore: + - 'docs/**' + - '*.md' + +jobs: + test: + runs-on: ${{matrix.os}} + + strategy: + matrix: + node-version: [18.x, 20.x, 21.x] + os: [ubuntu-latest, windows-latest] + steps: + - uses: actions/checkout@v4 + + - name: Use Node.js + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + + - name: Install + run: | + npm install + + - name: Lint + run: | + npm run lint + + - name: Run tests + run: | + npm run unit -- --reporter spec --reporter md:report.md + + - name: Upload report + shell: bash + if: success() || failure() + run: | + cat report.md >> "$GITHUB_STEP_SUMMARY" +``` ## License diff --git a/borp.js b/borp.js index 6ab82be..65cd868 100755 --- a/borp.js +++ b/borp.js @@ -35,10 +35,7 @@ const args = parseArgs({ reporter: { type: 'string', short: 'r', - default: [ - /* c8 ignore next 1 */ - process.stdout.isTTY ? 'spec' : 'tap' - ], + default: ['spec'], multiple: true } }, diff --git a/test/basic.test.js b/test/basic.test.js index 069eb39..4f32c32 100644 --- a/test/basic.test.js +++ b/test/basic.test.js @@ -24,10 +24,6 @@ test('ts-esm', async (t) => { names.delete(test.name) }) - stream.on('data', (test) => { - console.log(JSON.stringify(test)) - }) - await completed }) @@ -190,9 +186,3 @@ test('js-esm', async (t) => { await completed }) - -test('this fails on windows', async (t) => { - if (process.platform === 'win32') { - throw new Error('windows') - } -})