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

Test on all minimum supported Node.js versions #1170

Merged
merged 14 commits into from Jul 16, 2021
29 changes: 8 additions & 21 deletions .github/workflows/ci.yml
Expand Up @@ -14,47 +14,34 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
node: ["14", "12", engines]
node: ["12.20.0", "14.13.1", "16.0.0"]
exclude:
# On Windows, run tests with only the LTS environments.
- os: windows-latest
node: engines
node: "12.20.0"
- os: windows-latest
node: "14"
node: "16.0.0"
# On macOS, run tests with only the LTS environments.
- os: macOS-latest
node: engines
node: "12.20.0"
- os: macOS-latest
node: "14"
node: "16.0.0"

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2

- name: Get Node.js version from package.json
if: matrix.node == 'engines'
id: get-version
run: echo ::set-output name=node::$(npx --q minimum-node-version)

- uses: actions/setup-node@v2-beta
if: matrix.node != 'engines'
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}

- uses: actions/setup-node@v2-beta
if: matrix.node == 'engines'
with:
node-version: ${{steps.get-version.outputs.node}}

- run: npm install

- name: Test without coverage
if: matrix.node == 'engines'
run: npx mocha --colors --experimental-modules
- run: npm test -- --colors

# upload coverage only once
- name: Coveralls
uses: coverallsapp/github-action@master
if: matrix.node == '12' && matrix.os == 'ubuntu-latest'
if: matrix.node == '16.0.0' && matrix.os == 'ubuntu-latest'
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Expand Up @@ -13,7 +13,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v2-beta
uses: actions/setup-node@v2
with:
node-version: 14
- run: npm install
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/types.yml
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2-beta
- uses: actions/setup-node@v2

- run: npm install

Expand Down
8 changes: 4 additions & 4 deletions test/main.js
Expand Up @@ -607,7 +607,7 @@ describe('node-fetch', () => {
expect(res.status).to.equal(200);
expect(res.ok).to.be.true;
return expect(res.text()).to.eventually.be.rejectedWith(Error)
.and.have.property('message').matches(/Premature close|The operation was aborted/);
.and.have.property('message').matches(/Premature close|The operation was aborted|aborted/);
});
});

Expand All @@ -634,9 +634,9 @@ describe('node-fetch', () => {
const read = async body => {
const chunks = [];

if (process.version < 'v14') {
// In Node.js 12, some errors don't come out in the async iterator; we have to pick
// them up from the event-emitter and then throw them after the async iterator
if (process.version < 'v14.15.2') {
jimmywarting marked this conversation as resolved.
Show resolved Hide resolved
// In older Node.js versions, some errors don't come out in the async iterator; we have
// to pick them up from the event-emitter and then throw them after the async iterator
let error;
body.on('error', err => {
error = err;
Expand Down