Skip to content

Commit

Permalink
feat(tests): Add proper automated tests (#107)
Browse files Browse the repository at this point in the history
In order to prevent functional regressions, let's renovate our automated tests and use a proper test runner: [Ava](https://github.com/avajs/ava).

Although Node.js 12 is needed by Ava to run tests, `pdfreader` still works with Node.js 8+.
  • Loading branch information
adrienjoly authored Mar 25, 2022
1 parent 6d13ecf commit de56372
Show file tree
Hide file tree
Showing 12 changed files with 10,546 additions and 438 deletions.
42 changes: 31 additions & 11 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,52 @@ on:
- master

jobs:
check:
# Make sure that pdfreader can still run on old Node.js versions
old-node:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [8.x, 10.x]
steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm ci # install dependencies
- run: npm run test:samples

# Prevent functional regressions on supported Node.js versions
tests:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x, 14.x, 16.x]
steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: install deps
run: npm ci
env:
CI: true
- run: npm ci # install dependencies
- run: npm test
env:
CI: true

# Checks that files are formatted consistently
formatting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 16.x
- run: npm ci # install dependencies
- run: npm run prettier:check
env:
CI: true

release:
needs: check
needs:
- tests
- old-node
- formatting
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v10
v16
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ Summary:
- [Rule-based data extraction](#rule-based-data-extraction)
- [Troubleshooting & FAQ](#troubleshooting--faq)

## Installation, tests and CLI usage (make sure node v8 or v10)
## Installation, tests and CLI usage

```sh
nvm use # optional, to switch to the recommended version of Node.js
npm install pdfreader
cd node_modules/pdfreader
npm test
Expand Down
Loading

0 comments on commit de56372

Please sign in to comment.